java – Oracle.jdbc.driver.OracleDriver()不存在错误

我试图从java程序执行sql命令..我没有关于此代码的任何错误..但我面临来自数据库的连接拒绝..import java.sql.*;public class DBCreateTable{public static void main(String args[]) throws Exception{DriverMana...

我试图从java程序执行sql命令..我没有关于此代码的任何错误..但我面临来自数据库的连接拒绝..

import java.sql.*;
public class DBCreateTable
{
    public static void main(String args[]) throws Exception
    {
        DriverManager.registerDriver (new Oracle.jdbc.driver.OracleDriver());
        Connection con=DriverManager.getConnection(
              "jdbc:oracle:thin:@localhost:1521:xe","lms","abc");
        Statement stmt=con.CreateStatement();
        stmt.executeUpdate("create table emp(eno number(5),name varchar2(20))");
    }
}

遇到的错误是:

Exception in thread "main" java.sql.SQLException: Io exception: Connection refused(DESCRIPTION=(TMP=)(VSNNUM=185599488)(ERR=12505)(ERROR_STACK=(ERROR=(CODE=12505)(EMFI=4))))
        at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
        at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:179)
        at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:333)
        at oracle.jdbc.driver.OracleConnection.<init>(OracleConnection.java:404)
       at oracle.jdbc.driver.OracleDriver.getConnectionInstance(OracleDriver.ja
va:468)
        at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:314)
        at java.sql.DriverManager.getConnection(DriverManager.java:579)
        at java.sql.DriverManager.getConnection(DriverManager.java:221)
        at DBCreateTable.main(DBCreateTable.java:7)

在我的sql命令中,我已完成以下操作..

    SQL> connect system/tiger;
    SQL> create user lms identified by abc;
    SQL> grant connect,resource to lms;

并告诉我什么是斯科特老虎..我在那里弄得很多……那里的用户是什么……解锁怎么样?谢谢..

解决方法:

将oracle驱动程序jar添加到项目构建路径,它应该可以工作.
(例如http://mirrors.ibiblio.org/pub/mirrors/maven/mule/dependencies/maven1/oracle-jdbc/jars/ojdbc14.jar)

本文标题为:java – Oracle.jdbc.driver.OracleDriver()不存在错误

基础教程推荐