JB9 连 Oracle时出错 如果表emp为空 则正常运行如果emp有记录 有一条 或几条 都出错rs = stmt.executeQuery("insert ……");不出错。大虾们 帮忙解释一下~谢先 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 /** * * 连接数据库 * * 方法 getConnection() 和 closeConnection() * */import oracle.jdbc.driver.*;import java.io.*;import java.lang.reflect.Method;import java.lang.*;import java.sql.*;import java.util.*;import java.net.*;public class ConnectionDataBaseBean{ static Connection conn = null; public ConnectionDataBaseBean() { } /**get oracle connection*/ public static Connection getConnection() { try { Class.forName("oracle.jdbc.driver.OracleDriver"); conn = DriverManager.getConnection( "jdbc:oracle:thin:@localhost:1521:pdb", "scott", "tiger"); } catch (ClassNotFoundException errs) { System.err.println("ConnectionDataBaseBean.getConnection() ClassNotFoundException:" + errs.getMessage()); } catch (SQLException errs) { System.err.println("ConnectionDataBaseBean.getConnection()SQLException:" + errs.getMessage()); } return conn; } /**close oracle connection*/ public static void closeConnection() { try { if (conn != null) { conn.close(); } } catch (SQLException errs) { System.err.println("ConnectionDataBaseBean.closeConnection()SQLException:" + errs.getMessage()); } finally { conn = null; } }}/** * 用户合法性检测 * */import java.io.*;import java.lang.*;import java.sql.*;import java.util.*;import org.apache.struts.action.*;……public class CheckUserBean { static Connection conn; Statement stmt; ResultSet rs; private String str_Sql; private String str_id; private String str_password; private String str_identity; boolean boo_isvalidate=false; ActionErrors errors = new ActionErrors(); public boolean CheckUserBean(User user)throws Exception {/** 为了 测试 下面代码 暂时屏蔽掉了 str_id = user.getStr_id(); str_password = user.getStr_password(); str_identity = user.getStr_identity(); if (str_identity.equals("manager")) { str_Sql ="select * from emp where empno= '7934'"; System.err.println("db.executeQuery:select * from emp where empno= '7934'"); } else if(str_identity.equals("student")) { str_Sql = "Select User_Stu_ID,User_PassWord from UserInfo where User_Stu_ID ='" +str_id + "'and User_PassWord ='" +str_password + "' "; System.err.println("db.executeQuery:student do "); }*/ try { System.out.println(" succeed into try"); if (conn == null){ //测试用输出 System.out.println(" conn is null init conn …… ……"); conn = ConnectionDataBaseBean.getConnection();} if (conn != null) { //测试用输出 System.out.println(" conn inited "); stmt = conn.createStatement(); //测试用输出 System.out.println("createStatement succeed"); rs = stmt.executeQuery("select * from emp where empno= '7934'"); //测试用输出 System.out.println("EXE: select * from emp where empno= '7934'");// if (rs.next()) { boo_isvalidate = true; //测试用输出 System.out.println(“return in try:" +boo_isvalidate);// } } } catch (Exception ex) { System.err.println("db.executeQuery:much time again " + ex.getMessage()); } //测试用输出 System.out.println(“return:" +boo_isvalidate); return boo_isvalidate; }}/////////////////////////////////////////////////////////----------------以下是运行 出错过程————————///////////////////////////////////////////////////////////执行 select * from emp where empno= '7934'StandardWrapper[:invoker]: Loading container servlet invokerHttpConnector[8083] Starting background thread succeed into try conn is null init conn …… …… conn inited createStatement succeeddb.executeQuery:much time again ORA-00600: 内部错误代码,参数: [ttcgcshnd-1], [0], [], [], [], [], [], []return:false//PL/SQL运行结果//==========================================================================SQL*Plus: Release 9.0.1.0.1 - Production on D??úáù 1?? 10 13:12:09 2004(c) Copyright 2001 Oracle Corporation. All rights reserved.á??óμ?: Oracle9i Enterprise Edition Release 9.0.1.1.1 - ProductionWith the Partitioning optionJServer Release 9.0.1.1.1 - ProductionSQL> select * from emp where empno= '7934'; EMPNO ENAME JOB MGR HIREDATE SAL COMM---------- ---------- --------- ---------- ---------- ---------- ---------- DEPTNO---------- 7934 MILLER CLERK 7782 23-1?? -82 1300 10SQL>//================================================================================= 应用服务器用weblogic就行了。 写了个SQL语句,用到序列,希望大神指点一下 plsql 操作 海量数据 怎么才是效率最高的方式 如何根据字段里的表名(视图名)查表里(视图)的数据 ORACLE在SQLPLUS中如何查询到存在有哪些数据库,如何查询出某个数据库中有哪些表? Oracle xsql开发Web的优缺[高手请进] 如何检索两个字段分别重复而第三个字段不重复的纪录? 关于Oracle连接的问题? 急!!高分求救!!!我的C盘已满,怎样将正运行于C区的数据库完全转移到D盘??? 怎样得到两个日期之间的天数? 关于表的主键问题,希望得到大家意见 请高手推荐两本oracle 方面的书!! 如何查看存储过程的内容?
*
* 连接数据库
*
* 方法 getConnection() 和 closeConnection()
*
*/import oracle.jdbc.driver.*;
import java.io.*;
import java.lang.reflect.Method;
import java.lang.*;
import java.sql.*;
import java.util.*;
import java.net.*;public class ConnectionDataBaseBean
{
static Connection conn = null; public ConnectionDataBaseBean()
{
}
/**get oracle connection*/
public static Connection getConnection()
{
try
{
Class.forName("oracle.jdbc.driver.OracleDriver");
conn = DriverManager.getConnection(
"jdbc:oracle:thin:@localhost:1521:pdb", "scott", "tiger");
}
catch (ClassNotFoundException errs)
{
System.err.println("ConnectionDataBaseBean.getConnection() ClassNotFoundException:"
+ errs.getMessage());
}
catch (SQLException errs)
{
System.err.println("ConnectionDataBaseBean.getConnection()SQLException:"
+ errs.getMessage());
}
return conn;
}
/**close oracle connection*/
public static void closeConnection()
{
try
{
if (conn != null)
{
conn.close();
}
}
catch (SQLException errs)
{
System.err.println("ConnectionDataBaseBean.closeConnection()SQLException:"
+ errs.getMessage());
}
finally
{
conn = null;
}
}
}
/**
* 用户合法性检测
*
*/
import java.io.*;
import java.lang.*;
import java.sql.*;
import java.util.*;
import org.apache.struts.action.*;
……public class CheckUserBean {
static Connection conn;
Statement stmt;
ResultSet rs;
private String str_Sql;
private String str_id;
private String str_password;
private String str_identity;
boolean boo_isvalidate=false;
ActionErrors errors = new ActionErrors(); public boolean CheckUserBean(User user)throws Exception {/** 为了 测试 下面代码 暂时屏蔽掉了
str_id = user.getStr_id();
str_password = user.getStr_password();
str_identity = user.getStr_identity(); if (str_identity.equals("manager"))
{
str_Sql ="select * from emp where empno= '7934'";
System.err.println("db.executeQuery:select * from emp where empno= '7934'");
}
else if(str_identity.equals("student"))
{
str_Sql =
"Select User_Stu_ID,User_PassWord from UserInfo where User_Stu_ID ='"
+str_id + "'and User_PassWord ='" +str_password + "' ";
System.err.println("db.executeQuery:student do ");
}
*/ try {
System.out.println(" succeed into try");
if (conn == null){
//测试用输出
System.out.println(" conn is null init conn …… ……");
conn = ConnectionDataBaseBean.getConnection();}
if (conn != null) {
//测试用输出
System.out.println(" conn inited ");
stmt = conn.createStatement();
//测试用输出
System.out.println("createStatement succeed");
rs = stmt.executeQuery("select * from emp where empno= '7934'");
//测试用输出
System.out.println("EXE: select * from emp where empno= '7934'");
// if (rs.next()) {
boo_isvalidate = true;
//测试用输出
System.out.println(“return in try:" +boo_isvalidate);
// }
}
}
catch (Exception ex) {
System.err.println("db.executeQuery:much time again " + ex.getMessage());
}
//测试用输出
System.out.println(“return:" +boo_isvalidate);
return boo_isvalidate; }
}
///////////////////////////////////////////////////////
//----------------以下是运行 出错过程————————//
/////////////////////////////////////////////////////////执行 select * from emp where empno= '7934'StandardWrapper[:invoker]: Loading container servlet invoker
HttpConnector[8083] Starting background thread
succeed into try
conn is null init conn …… ……
conn inited
createStatement succeed
db.executeQuery:much time again ORA-00600: 内部错误代码,参数: [ttcgcshnd-1], [0], [], [], [], [], [], []
return:false
//PL/SQL运行结果
//==========================================================================
SQL*Plus: Release 9.0.1.0.1 - Production on D??úáù 1?? 10 13:12:09 2004(c) Copyright 2001 Oracle Corporation. All rights reserved.
á??óμ?:
Oracle9i Enterprise Edition Release 9.0.1.1.1 - Production
With the Partitioning option
JServer Release 9.0.1.1.1 - ProductionSQL> select * from emp where empno= '7934'; EMPNO ENAME JOB MGR HIREDATE SAL COMM
---------- ---------- --------- ---------- ---------- ---------- ----------
DEPTNO
----------
7934 MILLER CLERK 7782 23-1?? -82 1300
10SQL>
//=================================================================================