在JSP中巨难的ORACLE的连接问题,请高手指点. 用两个oracle配置一下服务器,一个配成100.10.10.10:1521 另一个配成100.10.10.11:1521然后可以用thin驱动程序来连接就可以了 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 JDBC的thin方式不能连接呀.....急呀..... //编写人:Conquer//编写时间:2001.07.31//类说明:此类完成对数据库的连接,对记录的删除,插入,更新等操作package system.pub;import java.sql.*;import oracle.jdbc.driver.*;public class oraclesql { Connection conn=null; ResultSet rs=null; Statement stmt=null; public int count=0; public boolean istrue; //连接数据库 public oraclesql() { try { Class.forName("oracle.jdbc.driver.OracleDriver"); } catch(Exception e) { System.err.println("Connection Driver is error for dirver!!!"); } try { //conn=DriverManager.getConnection("jdbc:db2//webdev/comunity","system","manager"); //try{ DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver()); //}catch(Exception e){ // System.err.println("registerDriver error"); //} conn=DriverManager.getConnection("jdbc:oracle:thin:scott/[email protected]:1521:konquersid"); //conn=DriverManager.getConnection("jdbc:oracle:scott/tiger@konquer"); stmt=conn.createStatement(); System.err.println("fuck"); } catch(Exception e) { System.err.println(e.toString()); System.err.println("Connection Database is error for connection!!!"); } } //执行记录的插入,删除 public void execUpdate(String sql) { try { stmt.executeUpdate(sql); istrue=true; } catch(Exception e) { System.err.println(sql+"---is error!!!"); istrue=false; } } //执行SELECT语句,返回数据集,并且可以通过全局变量count取得数据集中的记录数 public ResultSet execQuery(String sql) { String sql_t=sql; try { sql_t="select count(*) "+sql_t.substring(sql_t.indexOf("from"),sql_t.length()); ResultSet rs_c=stmt.executeQuery(sql_t); if(rs_c.next()) this.count=rs_c.getInt(1); } catch(Exception e) { System.err.println(sql+"---is error!!!"); } try { rs=stmt.executeQuery(sql); istrue=true; } catch(Exception e) { System.err.println(sql+"---is error!!!"); istrue=false; } return rs; } //断开和数据库的连接 public void CloseConn() { try { if(rs!=null) { rs.close(); rs=null; } if(conn!=null) { conn.close(); conn=null; } } catch(Exception e) { System.err.println("CloseConnection is error"); } }} 【疑惑】gxt 表格(RowExpander) 自动 扩张的问题。 IllegalStateException异常 Hibernate 一对一主键关联映射 无法保存 日志问题 请教 :关于 esponse.setHeader 导出excels问题 向大侠们求助,sessionFactory初始化问题 session问题,各位大侠请给帮助 jsp中java能否访问HTML里的值 高分求救 哪有JSP源程序下载:像csdn.net的文档部分的一样 在图片中插入可访问的图表(标记)?? weblogic配置问题。急急急
//编写人:Conquer
//编写时间:2001.07.31
//类说明:此类完成对数据库的连接,对记录的删除,插入,更新等操作
package system.pub;
import java.sql.*;
import oracle.jdbc.driver.*;
public class oraclesql { Connection conn=null;
ResultSet rs=null;
Statement stmt=null;
public int count=0;
public boolean istrue; //连接数据库
public oraclesql() {
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
}
catch(Exception e) {
System.err.println("Connection Driver is error for dirver!!!");
}
try {
//conn=DriverManager.getConnection("jdbc:db2//webdev/comunity","system","manager");
//try{
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
//}catch(Exception e){
// System.err.println("registerDriver error");
//}
conn=DriverManager.getConnection("jdbc:oracle:thin:scott/[email protected]:1521:konquersid");
//conn=DriverManager.getConnection("jdbc:oracle:scott/tiger@konquer");
stmt=conn.createStatement();
System.err.println("fuck");
}
catch(Exception e) {
System.err.println(e.toString());
System.err.println("Connection Database is error for connection!!!");
}
} //执行记录的插入,删除
public void execUpdate(String sql) {
try {
stmt.executeUpdate(sql);
istrue=true;
}
catch(Exception e) {
System.err.println(sql+"---is error!!!");
istrue=false;
}
} //执行SELECT语句,返回数据集,并且可以通过全局变量count取得数据集中的记录数
public ResultSet execQuery(String sql) {
String sql_t=sql;
try {
sql_t="select count(*) "+sql_t.substring(sql_t.indexOf("from"),sql_t.length());
ResultSet rs_c=stmt.executeQuery(sql_t);
if(rs_c.next())
this.count=rs_c.getInt(1);
}
catch(Exception e) {
System.err.println(sql+"---is error!!!");
} try {
rs=stmt.executeQuery(sql);
istrue=true;
}
catch(Exception e) {
System.err.println(sql+"---is error!!!");
istrue=false;
}
return rs;
} //断开和数据库的连接
public void CloseConn() {
try {
if(rs!=null) {
rs.close();
rs=null;
}
if(conn!=null) {
conn.close();
conn=null;
}
}
catch(Exception e) {
System.err.println("CloseConnection is error");
}
}
}