package hjSql;import java.sql.*;
import javax.swing.JOptionPane;
import hjutil.SystemConfig;public class SqlData { static String strCon = SystemConfig.getValue("Connection");
static String strDriver = SystemConfig.getValue("DriverName");
static String username = SystemConfig.getValue("UserName");
static String password = SystemConfig.getValue("Password"); static {
try {
Class.forName(strDriver).newInstance();
} catch (ClassNotFoundException e) {
JOptionPane.showMessageDialog(
null,
SystemConfig.getValue("Ec00001"),
SystemConfig.getValue("MessageTitle"),
JOptionPane.ERROR_MESSAGE); } catch (InstantiationException e) {
JOptionPane.showMessageDialog(
null,
SystemConfig.getValue("Ec00002"),
SystemConfig.getValue("MessageTitle"),
JOptionPane.ERROR_MESSAGE); } catch (Exception e) {
JOptionPane.showMessageDialog(
null,
SystemConfig.getValue("Ec99999"),
SystemConfig.getValue("MessageTitle"),
JOptionPane.ERROR_MESSAGE); }
} public SqlData() { } public static ResultSet doSql(String strSql) {
ResultSet rs = null; try {
Connection conn =
DriverManager.getConnection(strCon, username, password);
Statement stmt =
conn.createStatement(
ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_UPDATABLE);
rs = stmt.executeQuery(strSql);
//rs.last();
//System.out.println(rs.getRow());
//rs.first();
} catch (SQLException e) {
JOptionPane.showMessageDialog(
null,
SystemConfig.getValue("Ec00003"),
SystemConfig.getValue("MessageTitle"),
JOptionPane.ERROR_MESSAGE); }
return rs;
}
}