一个B/S的仓库管理系统放在买来的空间里,用JDBC连接数据库,SQL2000,
试用版用户使用的数据库名字为shiyong。一个正式版客户的数据库名为zhenshi。
在正式版客户使用系统的过程中,不知道怎么的就说连到shiyong上面去了,重新登录系统后又连接到zhenshi上.
请大家帮帮忙,看问题出在哪里,要怎么解决连接数据库的代码为:
package com.util
import java.sql.*;public class DBjdbc{
private Connection conn=null;
private Statement stmt=null;
private ResultSet rs=null;
private DBjdbc(){}
public Static String url;
public Static String dbname;
public Static String user;
public Static String psw;
public Static DBjdbc dbjdbc; public static void setDbName(String ss,String ip,String name,String dbpsw){
dbname = ss;
url = ip;
user = name;
psw = dbpsw;
} public static DBjdbc getInstance(){
if(dbjdbc == null){ dbjdbc = new DBjdbc(); }
return dbjdbc;
}
private Connection getConnection() throws SQLException,ClassNotFoundException{
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
this.conn = DriverManager.getConnection("jdbc:microsoft:sqlserver://"+url+":1433;ataBaseName="+dbname,user,psw);
return conn;
}
public ResultSet querySQL(String strSql) throws SQLException,ClassNotFoundException{
if(conn == null){ this.getConnection(); }
this.stmt = conn.createStatement();
rs = stmt.executeQuery(strSql);
return rs;
} public int updateResult(String strSql) throws SQLException,ClassNotFoundException{
if(conn == null){ this.getConnection(); }
this.stmt = conn.createStatement();
rs = stmt.executeUpdate(strSql);
return rs;
} public void closeConn() throws SQLException{
if(rs != null){
rs.close();
rs = null;
}
if(stmt!= null){
stmt.close();
stmt= null;
}
if(conn!= null){
conn.close();
conn= null;
}
}
}
试用版用户使用的数据库名字为shiyong。一个正式版客户的数据库名为zhenshi。
在正式版客户使用系统的过程中,不知道怎么的就说连到shiyong上面去了,重新登录系统后又连接到zhenshi上.
请大家帮帮忙,看问题出在哪里,要怎么解决连接数据库的代码为:
package com.util
import java.sql.*;public class DBjdbc{
private Connection conn=null;
private Statement stmt=null;
private ResultSet rs=null;
private DBjdbc(){}
public Static String url;
public Static String dbname;
public Static String user;
public Static String psw;
public Static DBjdbc dbjdbc; public static void setDbName(String ss,String ip,String name,String dbpsw){
dbname = ss;
url = ip;
user = name;
psw = dbpsw;
} public static DBjdbc getInstance(){
if(dbjdbc == null){ dbjdbc = new DBjdbc(); }
return dbjdbc;
}
private Connection getConnection() throws SQLException,ClassNotFoundException{
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
this.conn = DriverManager.getConnection("jdbc:microsoft:sqlserver://"+url+":1433;ataBaseName="+dbname,user,psw);
return conn;
}
public ResultSet querySQL(String strSql) throws SQLException,ClassNotFoundException{
if(conn == null){ this.getConnection(); }
this.stmt = conn.createStatement();
rs = stmt.executeQuery(strSql);
return rs;
} public int updateResult(String strSql) throws SQLException,ClassNotFoundException{
if(conn == null){ this.getConnection(); }
this.stmt = conn.createStatement();
rs = stmt.executeUpdate(strSql);
return rs;
} public void closeConn() throws SQLException{
if(rs != null){
rs.close();
rs = null;
}
if(stmt!= null){
stmt.close();
stmt= null;
}
if(conn!= null){
conn.close();
conn= null;
}
}
}
解决方案 »
- JQuery取后台List,在线等各位大侠们。。
- 求助高手org.hibernate.exception.SQLGrammarException: could not execute query ?
- 怎样让火狐浏览器支持这个CSS样式?
- jsp自动生成的servlet报错
- 网页设计的问题
- JSP设置ONFOCUS事件时发现的问题
- 问个弱弱的问题。
- javamail连接163的油箱问题
- 刚学JSP没有多久,想用JSP+文本形式开发留言本,不知道需要主要那些问题~~~~~~
- Date todate = new Date();取到的为什么不时当天的时间啊》?
- 如何实现可输入的下拉菜单?
- ssh框架中mysql数据的插入问题
把ss设置成shiyong了。所以用着用着就跑了。