用JSP写的一个在线购物网站的代码
源代码在线查看: conn.java
package shop.data;
import java.sql.*;
public class conn{
String dbdriver = "sun.jdbc.odbc.JdbcOdbcDriver";
String url = "JDBC:ODBC:shop";
Connection conn = null;
ResultSet rs = null;
public conn(){
try{
Class.forName(dbdriver);
}
catch(java.lang.ClassNotFoundException e){}
}
public ResultSet executeQuery(String sql){
rs = null;
try{
conn = DriverManager.getConnection(url,"sa","");
Statement com = conn.createStatement(java.sql.ResultSet.TYPE_SCROLL_INSENSITIVE,java.sql.ResultSet.CONCUR_READ_ONLY);
rs = com.executeQuery(sql);
}
catch(SQLException ex){ System.out.println(sql); }
return rs;
}
}