展开全部
package app63;
import java.sql.*;
public class DBconn {
String DBDriver = "sun.jdbc.odbc.JdbcOdbcDriver";
String Connstr = "jdbc:odbc:message";
Connection con = null;
ResultSet rs = null;
public DBconn(){
try{
Class.forName(DBDriver);
}
catch(ClassNotFoundException e){
System.out.println("DBconn:classnotfoundedception");
}
}
public void executeInsert(String s){
int i = 0;
Statement sql;
try{
con = DriverManager.getConnection(Connstr);
sql = con.createStatement();
i = sql.executeUpdate(s);
}
catch(SQLException sqlexception){
System.err.println("executeInsert:" + sqlexception.getMessage());
}
}
public ResultSet Querysimple(String s){
rs = null;
Statement sql;
try{
con = DriverManager.getConnection(Connstr);
sql = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_UPDATABLE);
rs = sql.executeQuery(s);
}
catch(SQLException sqlexception){
System.err.println("executeQuery:" + sqlexception.getMessage());
}
return rs;
}
public void executeDelete(String s){
Statement sql;
try{
con = DriverManager.getConnection(Connstr);
sql = con.createStatement();
sql.executeUpdate(s);
}
catch(SQLException sqlexception){
System.err.println("executeDelete:" + sqlexception.getMessage());
}
}
public int executeUpdate(String s){
int i =0;
Statement sql;
try{
con = DriverManager.getConnection(Connstr);
sql = con.createStatement();
i = sql.executeUpdate(s);
}
catch(SQLException sqlexception){
System.err.println("executeUpdate:" + sqlexception.getMessage());
}
return i;
}
public void close(){
try{
if(rs != null)
rs.close();
if(con != null)
con.close();
}
catch(SQLException sqlexception){
System.err.println("close:" + sqlexception.getMessage());
}
}
}
import java.sql.*;
public class DBconn {
String DBDriver = "sun.jdbc.odbc.JdbcOdbcDriver";
String Connstr = "jdbc:odbc:message";
Connection con = null;
ResultSet rs = null;
public DBconn(){
try{
Class.forName(DBDriver);
}
catch(ClassNotFoundException e){
System.out.println("DBconn:classnotfoundedception");
}
}
public void executeInsert(String s){
int i = 0;
Statement sql;
try{
con = DriverManager.getConnection(Connstr);
sql = con.createStatement();
i = sql.executeUpdate(s);
}
catch(SQLException sqlexception){
System.err.println("executeInsert:" + sqlexception.getMessage());
}
}
public ResultSet Querysimple(String s){
rs = null;
Statement sql;
try{
con = DriverManager.getConnection(Connstr);
sql = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_UPDATABLE);
rs = sql.executeQuery(s);
}
catch(SQLException sqlexception){
System.err.println("executeQuery:" + sqlexception.getMessage());
}
return rs;
}
public void executeDelete(String s){
Statement sql;
try{
con = DriverManager.getConnection(Connstr);
sql = con.createStatement();
sql.executeUpdate(s);
}
catch(SQLException sqlexception){
System.err.println("executeDelete:" + sqlexception.getMessage());
}
}
public int executeUpdate(String s){
int i =0;
Statement sql;
try{
con = DriverManager.getConnection(Connstr);
sql = con.createStatement();
i = sql.executeUpdate(s);
}
catch(SQLException sqlexception){
System.err.println("executeUpdate:" + sqlexception.getMessage());
}
return i;
}
public void close(){
try{
if(rs != null)
rs.close();
if(con != null)
con.close();
}
catch(SQLException sqlexception){
System.err.println("close:" + sqlexception.getMessage());
}
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询