connDb.java
上传用户:mingda
上传日期:2017-06-20
资源大小:27691k
文件大小:1k
- //package test;
- import java.sql.*;
- public class connDb {
- String sDBDriver = "sun.jdbc.odbc.JdbcOdbcDriver";
- String sConnStr = "jdbc:odbc:webprint";
- Connection conn = null;
- ResultSet rs = null;
- public connDb() {
- try {
- Class.forName(sDBDriver);
- }
- catch(java.lang.ClassNotFoundException e) {
- System.err.println("connDb(): " + e.getMessage());
- }
- }
- public ResultSet executeQuery(String sql) {
- rs = null;
- try {
- conn = DriverManager.getConnection(sConnStr);
- Statement stmt = conn.createStatement();
- rs = stmt.executeQuery(sql);
- }
- catch(SQLException ex) {
- System.err.println("connDb.executeQuery: " + ex.getMessage());
- }
- return rs;
- }
- }