用同一个应用程序连接WINDOWS数据库正常,但是连接solaris数据库失败,两个库结构相同。solaris监听没问题。

解决方案 »

  1.   

    都是oracle数据库.连接windows服务器正常,但连接solaris服务器异常,在客户端用SQLPLUS可以连上
    java.sql.SQLException: Io 异常: Connection refused(DESCRIPTION=(TMP=)(VSNNUM=153092352)(ERR=12505)(ERROR_STACK=(ERROR=(CODE=12505)(EMFI=4))))
      

  2.   

    Oracle错误号 12505 连接不上数据库Listener
     Listener有没有启动, 数据库端口号有没有配置正确?
      

  3.   

    private void transPHOTO(String cond){ String url_source = "jdbc:oracle:thin:@10.106.184.200:1521:pcsdb";
    String user_source = "ipos_cc";
    String pass_source = "sysmanager"; String url_target = "jdbc:oracle:thin:@10.106.184.200:1521:pcsdb";
    String user_target = "ipos_cc";
    String pass_target = "sysmanager"; int size = 1000;
    int count = 0; String width = "120";
    String height = "150"; Connection conn_source=null;
    Connection conn_target=null; Statement stmt_source = null;
    ResultSet rs_source = null; PreparedStatement ps_target = null;
    ResultSet rs_target = null; BLOB zp = null;
    byte[] data = new byte[1024 * 64]; long star = System.currentTimeMillis(); String sql_selzp = " select * from v_rkzp where zpbh like '" +
     cond + "%' order by zpbh"; String sql_inert = " insert into t_rkzpb(zpbh,rybh,zp,cjsj,width,height) "+
     " values(?,?,empty_blob(),?,?,?)";
    try{
     Class.forName(SystemConstant.DB_DRIVER);
     conn_source = DriverManager.getConnection(url_source,user_source,pass_source);
     conn_source.setAutoCommit(false);  conn_target = DriverManager.getConnection(url_target,user_target,pass_target);
     conn_target.setAutoCommit(false);  stmt_source = conn_source.createStatement();
     rs_source = stmt_source.executeQuery(sql_selzp);
     rs_source.setFetchSize(2000);  while(rs_source.next()){
    data = rs_source.getBytes("zp");
    String str_zpbh = "2201" + rs_source.getString("zpbh");
    String str_rybh = "2201" + rs_source.getString("rybh");
    String str_cjsj = rs_source.getString("smsj"); ps_target = conn_target.prepareStatement(sql_inert);
    ps_target.setString(1,str_zpbh);
    ps_target.setString(2,str_rybh);
    ps_target.setString(3,str_cjsj);
    ps_target.setString(4,width);
    ps_target.setString(5,height);
    ps_target.execute();
    ps_target.close(); String sql_select = " select zp from t_rkzpb where zpbh ='" + str_zpbh + "' for update";
    //String sql_update = " update t_rkzpb set zp = ? where zpbh='" + str_zpbh + "'";
    ps_target = conn_target.prepareStatement(sql_select);
    rs_target = ps_target.executeQuery();
    if(rs_target.next()){
     zp = (BLOB)rs_target.getBlob(1);
     BufferedOutputStream out = new BufferedOutputStream(zp.getBinaryOutputStream());
     out.write(data,0,data.length);
     out.close();
    }
    rs_target.close();
    ps_target.close();
    //conn_target.commit(); /*ps_target = conn_target.prepareStatement(sql_update);
    ps_target.setBlob(1,zp);
    ps_target.executeUpdate();
    ps_target.close();*/
    if(++count % size == 0){
     conn_target.commit();
     long stop = System.currentTimeMillis();
     float second = (stop - star) / 1000;
     System.out.println(count + " 条照片用时:" + second + " 秒!");
    }
     }
     conn_target.commit();
     rs_target.close();
     ps_target.close();
     conn_source.close();
     conn_target.close();
    }
    catch(SQLException sqlex){
     sqlex.printStackTrace();
     try{
    if(rs_target != null)
     rs_target.close();
    if(ps_target != null)
     ps_target.close(); if(rs_source != null)
     rs_source.close();
    if(stmt_source != null)
     stmt_source.close();
     }
     catch(SQLException sex){
    System.out.println("Exception -----2");
     }
    }
    catch(IOException ioex){
     System.out.println("Exception -----3");
     ioex.printStackTrace();
    }
    catch(Exception ex){ }
    finally{
     zp = null;
     data = null;
    }
    }
      

  4.   

    上面的代码连其他数据库正常, Listener也启动了,端口号也对,但就是连不上呢?