jsp连接数据库的.java文件 对语句求高手写出注释 麻烦了
packageckstudio.db;importjava.io.PrintStream;importjava.sql.*;publicclassfaq{StringsD...
package ckstudio.db;
import java.io.PrintStream;
import java.sql.*;
public class faq
{
String sDBDriver = null;
String sConnStr = null;
Connection conn = null;
ResultSet rs = null;
public faq()
{
sDBDriver = "sun.jdbc.odbc.JdbcOdbcDriver";
sConnStr = "jdbc:odbc:hill";
conn = null;
rs = null;
try
{
Class.forName(sDBDriver);
}
catch(ClassNotFoundException classnotfoundexception)
{
System.err.println("faq(): " + classnotfoundexception.getMessage());
}
}
public void executeInsert(String s)
{
try
{
conn = DriverManager.getConnection(sConnStr);
Statement statement = conn.createStatement();
int i = statement.executeUpdate(s);
}
catch(SQLException sqlexception)
{
System.err.println("faq.executeUpdate:" + sqlexception.getMessage());
}
}
public ResultSet executeQuery(String s)
{
rs = null;
try
{
conn = DriverManager.getConnection(sConnStr);
Statement statement = conn.createStatement(1004, 1008);
rs = statement.executeQuery(s);
}
catch(SQLException sqlexception)
{
System.err.println("aq.executeQuery: " + sqlexception.getMessage());
}
return rs;
}
public void executeDelete(String s)
{
try
{
conn = DriverManager.getConnection(sConnStr);
Statement statement = conn.createStatement();
statement.executeUpdate(s);
}
catch(SQLException sqlexception)
{
System.err.println("faq.executeDelete: " + sqlexception.getMessage());
}
}
public int executeUpdate(String s)
{
int i = 0;
try
{
conn = DriverManager.getConnection(sConnStr);
Statement statement = conn.createStatement();
i = statement.executeUpdate(s);
}
catch(SQLException sqlexception)
{
System.err.println("faq.executeDelete: " + sqlexception.getMessage());
}
return i;
}
public void Close()
{
try
{
if(rs != null)
rs.close();
if(conn != null)
conn.close();
}
catch(SQLException sqlexception)
{
System.err.println("faq.executeDelete: " + sqlexception.getMessage());
}
}
} 展开
import java.io.PrintStream;
import java.sql.*;
public class faq
{
String sDBDriver = null;
String sConnStr = null;
Connection conn = null;
ResultSet rs = null;
public faq()
{
sDBDriver = "sun.jdbc.odbc.JdbcOdbcDriver";
sConnStr = "jdbc:odbc:hill";
conn = null;
rs = null;
try
{
Class.forName(sDBDriver);
}
catch(ClassNotFoundException classnotfoundexception)
{
System.err.println("faq(): " + classnotfoundexception.getMessage());
}
}
public void executeInsert(String s)
{
try
{
conn = DriverManager.getConnection(sConnStr);
Statement statement = conn.createStatement();
int i = statement.executeUpdate(s);
}
catch(SQLException sqlexception)
{
System.err.println("faq.executeUpdate:" + sqlexception.getMessage());
}
}
public ResultSet executeQuery(String s)
{
rs = null;
try
{
conn = DriverManager.getConnection(sConnStr);
Statement statement = conn.createStatement(1004, 1008);
rs = statement.executeQuery(s);
}
catch(SQLException sqlexception)
{
System.err.println("aq.executeQuery: " + sqlexception.getMessage());
}
return rs;
}
public void executeDelete(String s)
{
try
{
conn = DriverManager.getConnection(sConnStr);
Statement statement = conn.createStatement();
statement.executeUpdate(s);
}
catch(SQLException sqlexception)
{
System.err.println("faq.executeDelete: " + sqlexception.getMessage());
}
}
public int executeUpdate(String s)
{
int i = 0;
try
{
conn = DriverManager.getConnection(sConnStr);
Statement statement = conn.createStatement();
i = statement.executeUpdate(s);
}
catch(SQLException sqlexception)
{
System.err.println("faq.executeDelete: " + sqlexception.getMessage());
}
return i;
}
public void Close()
{
try
{
if(rs != null)
rs.close();
if(conn != null)
conn.close();
}
catch(SQLException sqlexception)
{
System.err.println("faq.executeDelete: " + sqlexception.getMessage());
}
}
} 展开
展开全部
package ckstudio.db;
import java.io.PrintStream;
import java.sql.*;
public class faq
{
String sDBDriver = null;
String sConnStr = null;
Connection conn = null; //定义连接
ResultSet rs = null; //定义结果集
public faq()
{
sDBDriver = "sun.jdbc.odbc.JdbcOdbcDriver"; //驱动程序
sConnStr = "jdbc:odbc:hill";
conn = null; /*初始化变量
rs = null; */
try
{
Class.forName(sDBDriver); //加载驱动程序
}
catch(ClassNotFoundException classnotfoundexception) //捕获的异常
{
System.err.println("faq(): " + classnotfoundexception.getMessage()); //输入捕获的异常信息
}
}
public void executeInsert(String s) //插入语句块
{
try
{
conn = DriverManager.getConnection(sConnStr); //连接
Statement statement = conn.createStatement(); //创建状态集
int i = statement.executeUpdate(s); //对数据库进行添加操作
}
catch(SQLException sqlexception)
{
System.err.println("faq.executeUpdate:" + sqlexception.getMessage()); //捕获插入异常信息
}
}
public ResultSet executeQuery(String s) //查询语句块
{
rs = null;
try
{
conn = DriverManager.getConnection(sConnStr);
Statement statement = conn.createStatement(1004, 1008);
rs = statement.executeQuery(s); //对数据库进行查询操作
}
catch(SQLException sqlexception)
{
System.err.println("aq.executeQuery: " + sqlexception.getMessage()); //捕获查询异常信息
}
return rs;
}
public void executeDelete(String s) //删除语句块
{
try
{
conn = DriverManager.getConnection(sConnStr);
Statement statement = conn.createStatement();
statement.executeUpdate(s); //对数据块进行删除操作
}
catch(SQLException sqlexception)
{
System.err.println("faq.executeDelete: " + sqlexception.getMessage());
}
}
public int executeUpdate(String s) //修改语句块
{
int i = 0;
try
{
conn = DriverManager.getConnection(sConnStr);
Statement statement = conn.createStatement();
i = statement.executeUpdate(s); //对数据库进行修改操作
}
catch(SQLException sqlexception)
{
System.err.println("faq.executeDelete: " + sqlexception.getMessage());
}
return i;
}
public void Close()
{
try
{
if(rs != null) //判断结果集是否为空
rs.close(); //为空——关闭结果集
if(conn != null) //判断连接是否为空
conn.close(); //为空——断开连接
}
catch(SQLException sqlexception)
{
System.err.println("faq.executeDelete: " + sqlexception.getMessage());
}
}
}
import java.io.PrintStream;
import java.sql.*;
public class faq
{
String sDBDriver = null;
String sConnStr = null;
Connection conn = null; //定义连接
ResultSet rs = null; //定义结果集
public faq()
{
sDBDriver = "sun.jdbc.odbc.JdbcOdbcDriver"; //驱动程序
sConnStr = "jdbc:odbc:hill";
conn = null; /*初始化变量
rs = null; */
try
{
Class.forName(sDBDriver); //加载驱动程序
}
catch(ClassNotFoundException classnotfoundexception) //捕获的异常
{
System.err.println("faq(): " + classnotfoundexception.getMessage()); //输入捕获的异常信息
}
}
public void executeInsert(String s) //插入语句块
{
try
{
conn = DriverManager.getConnection(sConnStr); //连接
Statement statement = conn.createStatement(); //创建状态集
int i = statement.executeUpdate(s); //对数据库进行添加操作
}
catch(SQLException sqlexception)
{
System.err.println("faq.executeUpdate:" + sqlexception.getMessage()); //捕获插入异常信息
}
}
public ResultSet executeQuery(String s) //查询语句块
{
rs = null;
try
{
conn = DriverManager.getConnection(sConnStr);
Statement statement = conn.createStatement(1004, 1008);
rs = statement.executeQuery(s); //对数据库进行查询操作
}
catch(SQLException sqlexception)
{
System.err.println("aq.executeQuery: " + sqlexception.getMessage()); //捕获查询异常信息
}
return rs;
}
public void executeDelete(String s) //删除语句块
{
try
{
conn = DriverManager.getConnection(sConnStr);
Statement statement = conn.createStatement();
statement.executeUpdate(s); //对数据块进行删除操作
}
catch(SQLException sqlexception)
{
System.err.println("faq.executeDelete: " + sqlexception.getMessage());
}
}
public int executeUpdate(String s) //修改语句块
{
int i = 0;
try
{
conn = DriverManager.getConnection(sConnStr);
Statement statement = conn.createStatement();
i = statement.executeUpdate(s); //对数据库进行修改操作
}
catch(SQLException sqlexception)
{
System.err.println("faq.executeDelete: " + sqlexception.getMessage());
}
return i;
}
public void Close()
{
try
{
if(rs != null) //判断结果集是否为空
rs.close(); //为空——关闭结果集
if(conn != null) //判断连接是否为空
conn.close(); //为空——断开连接
}
catch(SQLException sqlexception)
{
System.err.println("faq.executeDelete: " + sqlexception.getMessage());
}
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询