Home » Source Code » accessdata

accessdata

meng7even
2013-11-26 10:01:24
The author
View(s):
Download(s): 0
Point (s): 1 
Category Category:
Java DevelopmentJava Development JavaJava

Description

package com.access.util;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Locale;
import java.util.ResourceBundle;
public class DataToolForAccess {
private static DataToolForAccess dto = null;
private static Connection con = null;
public Connection getOrecal() {
try {
Locale locale = Locale.getDefault();
ResourceBundle rb = ResourceBundle.getBundle("com/database/accessPath",
locale);
String path = rb.getString("path");
path=UserManagerInfo.decrypt3DES(path);
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String strurl = "jdbc:odbc:driver={Microsoft Access Driver (*.mdb)};DBQ=d://att2000.mdb";//+path;
con = DriverManager.getConnection(strurl);
}
//Exception throwing
catch (Exception e) {
System.out.println(e);
}
return con;
}
public boolean execUpdate(String opretorSQl) {
if ((opretorSQl == null) || opretorSQl.trim().equals("")) {
return true;
}
Statement stmt = null;
int nRowCount = 0;
try {
stmt = con.createStatement();
nRowCount = stmt.executeUpdate(opretorSQl);
stmt.executeUpdate("commit");
stmt.close();
stmt = null;
} catch (SQLException ex) {
try {
stmt.close();
} catch (SQLException e) {
e.printStackTrace();
}
System.err.println(ex.getMessage());
System.out.println(opretorSQl);
System.err.println ("unable to perform an update operation! Verify that the query is correct. ");
return false;
}
return true;


}
private DataToolForAccess() {
getOrecal();
}
public static DataToolForAccess getInstanceDTO() {


if (dto == null) {
dto = new DataToolForAccess();
}
return dto;
}
public ResultSet execQuery(String querySql) {
ResultSet rs = null;
try {
Statement st = con.createStatement();
rs = st.executeQuery(querySql);
} catch (Exception e) {
System.out.println ("preparing to create a connection to the database failed");
e.printStackTrace();
}
return rs;
}
public boolean closeResult(ResultSet rs) {
boolean flog = false;
if (rs == null) {
return flog;
}
Statement stmt = null;
try {
stmt = rs.getStatement();
} catch (SQLException e) {
e.printStackTrace();
}
try {
rs.close();
if (stmt != null) {
stmt.close();
stmt = null;
}
} catch (SQLException ex) {
}
return flog;
}
}

Sponsored links

File list

Tips: You can preview the content of files by clicking file names^_^
Name Size Date
DataToolForAccess.java2.37 kB2013-11-21 11:17
...
Sponsored links

Comments

(Add your comment, get 0.1 Point)
Minimum:15 words, Maximum:160 words
  • 1
  • Page 1
  • Total 1

accessdata (1.08 kB)

Need 1 Point(s)
Your Point (s)

Your Point isn't enough.

Get 22 Point immediately by PayPal

Point will be added to your account automatically after the transaction.

More(Debit card / Credit card / PayPal Credit / Online Banking)

Submit your source codes. Get more Points

LOGIN

Don't have an account? Register now
Need any help?
Mail to: support@codeforge.com

切换到中文版?

CodeForge Chinese Version
CodeForge English Version

Where are you going?

^_^"Oops ...

Sorry!This guy is mysterious, its blog hasn't been opened, try another, please!
OK

Warm tip!

CodeForge to FavoriteFavorite by Ctrl+D