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();
}


}
}
...全文
26 点赞 收藏 回复
写回复
回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
相关推荐
发帖
Web 开发
创建于2007-09-28

8.0w+

社区成员

Java Web 开发
申请成为版主
帖子事件
创建了帖子
2004-09-15 03:06
社区公告
暂无公告