gogollili(孤夜白星)请你再次指导!我这么改对不对..你看看..谢谢..

keller_7910 2004-09-15 03:06:53
package opendb;

import java.sql.*;

public class opendb {

String sDBDriver = "com.microsoft.jdbc.sqlserver.SQLServerDriver";
String sConnStr = "jdbc:microsoft qlserver://localhost:1433;DatabaseName=zhang";
Connection conn = null;
ResultSet rs = null;
Statement stmt=null;
public opendb()
{
try
{
Class.forName(sDBDriver);
}
catch (java.lang.ClassNotFoundException e)
{
System.err.println("opendb(): " + e.getMessage());
}
}
public void getConnection()
{
try{
conn=DriverManager.getConnection(sConnStr,"sa","");
}catch(Exception e){}
}


public ResultSet executeQuery(String sql)
{
try
{
stmt = conn.createStatement();
rs = stmt.executeQuery(sql);
}
catch (SQLException ex)
{
System.err.println("aq.executeQuery: " + ex.getMessage());
}
return rs;
rs.close();
stmt.close();
}

public void executeUpdate(String sql)
{

try
{

stmt = conn.createStatement();
stmt.executeUpdate(sql);
}
catch (SQLException ex) {
System.err.println("aq.executeQuery: " + ex.getMessage());
rs.close();
stmt.close();
}


}
}
...全文
54 回复 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

81,122

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧