当前位置: 技术问答>java相关
帮帮忙啊,回答就有分
来源: 互联网 发布时间:2015-02-23
本文导语: import java.sql.*; public class DBconn { String DBDriver = "sun.jdbc.odbc.JdbcOdbcDriver"; String ConnStr = "jdbc:odbc:Customers"; Connection conn = null; ResultSet rs = null; public DBconn { //这一行为什么会出错:"DBconn.java": Error #: 200 :...
import java.sql.*;
public class DBconn {
String DBDriver = "sun.jdbc.odbc.JdbcOdbcDriver";
String ConnStr = "jdbc:odbc:Customers";
Connection conn = null;
ResultSet rs = null;
public DBconn { //这一行为什么会出错:"DBconn.java": Error #: 200 : expected at line 13, column 15
try {
Class.forName(DBDriver);
//加载数据库驱动程序
}
catch(java.lang.ClassNotFoundException e) {
System.err.println("DBconn (): " + e.getMessage());
}
}
public ResultSet executeQuery(String sql) {
rs = null;
try {
conn = DriverManager.getConnection(ConnStr);
//与DBMS建立连接
Statement stmt = conn.createStatement();
rs = stmt.executeQuery(sql);
}
catch(SQLException ex) {
System.err.println("aq.executeQuery: " + ex.getMessage());
}
return rs;
}
}
public class DBconn {
String DBDriver = "sun.jdbc.odbc.JdbcOdbcDriver";
String ConnStr = "jdbc:odbc:Customers";
Connection conn = null;
ResultSet rs = null;
public DBconn { //这一行为什么会出错:"DBconn.java": Error #: 200 : expected at line 13, column 15
try {
Class.forName(DBDriver);
//加载数据库驱动程序
}
catch(java.lang.ClassNotFoundException e) {
System.err.println("DBconn (): " + e.getMessage());
}
}
public ResultSet executeQuery(String sql) {
rs = null;
try {
conn = DriverManager.getConnection(ConnStr);
//与DBMS建立连接
Statement stmt = conn.createStatement();
rs = stmt.executeQuery(sql);
}
catch(SQLException ex) {
System.err.println("aq.executeQuery: " + ex.getMessage());
}
return rs;
}
}
|
public DBconn {
==>
public DBconn() {
==>
public DBconn() {