用两个oracle配置一下服务器,一个配成100.10.10.10:1521 另一个配成100.10.10.11:1521然后可以用thin驱动程序来连接就可以了

解决方案 »

  1.   

    JDBC的thin方式不能连接呀.....急呀.....
      

  2.   


    //编写人: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");
        }
      }
    }