5个回答
推荐于2018-04-12
展开全部
数据库正在使用当中,你把那些已经打开的属于JBNewsDB数据库的表要全部关闭,还有在新建查询下面的工具栏里的数据库名称也不要是JBNewsDB,把它改成master就行了
2013-06-05
展开全部
package com.chinamobile.model;import java.io.IOException;
import java.io.InputStream;
import java.sql.*;
import java.util.Properties;public class DbUtil {
public Connection conn;
public CallableStatement cs;
public ResultSet rs; public DbUtil() {
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} Properties ps = new Properties();
InputStream is = DbUtil.class.getClassLoader().getResourceAsStream(
"config.properties");
try {
ps.load(is);
is.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} String url = ps.getProperty("url");
String userName = ps.getProperty("userName");
String pwd = ps.getProperty("password");
try {
conn = DriverManager.getConnection(url, userName, pwd);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} public ResultSet select(String sql) {
try {
cs = conn.prepareCall(sql, ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_UPDATABLE);
rs = cs.executeQuery();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return rs;
} public int update(String sql) {
int rows = 0;// 表示sql语句执行时受影响的行数
try {
cs = conn.prepareCall(sql);
rows = cs.executeUpdate();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return rows;
} public void close() {
if (rs != null) {
try {
rs.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} if (cs != null) {
try {
cs.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} if (conn != null) {
try {
conn.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
import java.io.InputStream;
import java.sql.*;
import java.util.Properties;public class DbUtil {
public Connection conn;
public CallableStatement cs;
public ResultSet rs; public DbUtil() {
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} Properties ps = new Properties();
InputStream is = DbUtil.class.getClassLoader().getResourceAsStream(
"config.properties");
try {
ps.load(is);
is.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} String url = ps.getProperty("url");
String userName = ps.getProperty("userName");
String pwd = ps.getProperty("password");
try {
conn = DriverManager.getConnection(url, userName, pwd);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} public ResultSet select(String sql) {
try {
cs = conn.prepareCall(sql, ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_UPDATABLE);
rs = cs.executeQuery();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return rs;
} public int update(String sql) {
int rows = 0;// 表示sql语句执行时受影响的行数
try {
cs = conn.prepareCall(sql);
rows = cs.executeUpdate();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return rows;
} public void close() {
if (rs != null) {
try {
rs.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} if (cs != null) {
try {
cs.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} if (conn != null) {
try {
conn.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2013-06-05
展开全部
conn.close();//关闭数据库连接
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2013-06-05
展开全部
先执行一个其他的库或默认库再删除你的那个库
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2013-06-05
展开全部
use master先运行这个在执行你的语句
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询