免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1169 | 回复: 3
打印 上一主题 下一主题

连接oracle [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2004-02-19 23:33 |只看该作者 |倒序浏览
我是oracle新手,连接oracle时出现问题package oracle.jdbc does not exist,请各位指教,谢谢!

论坛徽章:
0
2 [报告]
发表于 2004-02-20 08:43 |只看该作者

连接oracle

你是用ODBC还是JDBC连接,具体环境如何?

论坛徽章:
0
3 [报告]
发表于 2004-02-20 17:04 |只看该作者

连接oracle

我在solaris系统下用JDBC连
程序是这样的:import java.sql.*;
import javax.sql.*;
import oracle.jdbc.driver.*;

public class Ora8iConnect{
  private Connection conn;        //
  private String dbNAME;                //
  private String userID;                //
  private String userPWD;                //       
  
  public  Ora8iConnect(String db,String id,String pwd){
    dbNAME = db;
    userID = id;
    userPWD = pwd;
    beginConnect();                //               
  }
       
  public Connection getConnection(){
    return conn;
  }
  
  public int beginConnect(){
    try {       
      DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
      conn = DriverManager.getConnection("jdbcracleci8"+dbNAME,userID,userPWD);
      return 1;               
    }
    catch(SQLException e) {        //SQL
     System.out.println("Ora8iConnectoracle8";
     while (e!=null) {
       System.out.println("SQLState:" + e.getSQLState());
       System.out.println("Message :" + e.getMessage());
       System.out.println("Vendor  :" + e.getErrorCode());
       e=e.getNextException();
       System.out.println(" ";
      }
    conn = null;
    return 0;
   }
   }               

public static void main(String args[]){
    Ora8iConnect oc = new Ora8iConnect("SHMTU_202.121.211.158","tdx","tdx";
    oc.getConnection();
}
}
编译通过,但运行时main函数出现错误
请多多指教,谢谢!

论坛徽章:
0
4 [报告]
发表于 2004-02-20 17:10 |只看该作者

连接oracle

@<db host>;:<db port>;:<db SID>;","scott","tiger"
把@后面改成这样看看,应该有port的,一般为 1521,没做过oci的,推断的,感觉没有sid,和post是无法连数据库的。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP