简体   繁体   English

通过Java连接到Oracle 10g Express Edition的问题

[英]problem in connecting to oracle 10g express edition through java

I'm unable to connect Oracle 10g database.I am getting exception java.lang.ClassNotFoundException:oracle.jdbc.driver.OracleDriver 我无法连接Oracle 10g数据库。我收到异常java.lang.ClassNotFoundException:oracle.jdbc.driver.OracleDriver

The code is: 代码是:

try {
    Class.forName("oracle.jdbc.driver.OracleDriver");
}
catch(ClassNotFoundException e) {
    e.printStackTrace();
}

try {
    con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:system","user" ,"pass");
    stmt=con.createStatement();
}

....... .......

How can i proceed? 我该怎么办?

First, you have a space " " in your driver class name 首先,驱动程序类名称中有一个空格" "

Change, 更改,

Class.forName("oracle.jdbc.driver.OracleDrive r");

to, 至,

Class.forName("oracle.jdbc.driver.OracleDriver");

Also, fix this error from: 另外,从以下位置修复此错误:

DriverManager.getConnection("jdbc:oracle: thin:@localhost:1521:system","user" ,"pass");

to

DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:system","user" ,"pass");

您可能需要在“ jdbc:oracle:thin:@localhost:1521:system”中用XE替换系统。

Its a problem with the given url. 它是给定网址的问题。 Please correct the url with accurate host name,port no,user name & password.Do not use the port number(8080) that you are using with browser when you are running you application oracle 10g express edition.Simply user the default port number 1521. 请使用正确的主机名,端口号,用户名和密码来更正该url。在运行oracle 10g Express Edition应用程序时,请勿使用与浏览器一起使用的端口号(8080)。只需使用默认端口号1521 。

Please find the example below:- 请在下面找到示例:

String driver="oracle.jdbc.driver.OracleDriver";            

Class.forName(driver);
Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE","manoj","manoj");
  • user name=manoj 用户名= manoj
  • password=manoj 密码=马诺
  • port no=1521 端口号= 1521
  • service name=XE 服务名称= XE
  • Host=Localhost 主机=本地主机

删除'e'和'r'之间的空格?

您的类路径中有Oracle驱动程序吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM