No suitable driver found for “jdbc:oracle:thin:@**** ”oracle/jdbc/driver/OracleDriver";

前端 未结 3 1967
灰色年华
灰色年华 2021-01-19 02:47

here is my java code

public static Map propertyFileReader() {
    Map map=new HashMap();
           


        
相关标签:
3条回答
  • 2021-01-19 03:26

    You are using wrong package to refer OracleDriver class
    Change

    oracle.jdbc.driver.OracleDriver  
    

    To

    oracle.jdbc.OracleDriver  
    

    From oracle docs class definition

    public class OracleDriver
                  extends oracle.jdbc.driver.OracleDriver
    

    The Oracle JDBC driver class that implements the java.sql.Driver interface.

    0 讨论(0)
  • 2021-01-19 03:39

    Use this as Oracle Driver

    oracle.jdbc.OracleDriver 
    

    instead of

    oracle.jdbc.driver.OracleDriver
    
    0 讨论(0)
  • 2021-01-19 03:46

    This answer is a "bit" late, but the accepted answer is not correct, so I post this for anybody unfortunate enough to attempt to copy/paste the code and wondering what went wrong.

    The accepted answer is so far correct that

    oracle.jdbc.driver.OracleDriver

    is deprecated, but it is still working in 2020. The problem with the posted code is that the properties file is using semicolons and quotation marks, which are not valid. So changing the properties file from

    DB_DRIVER = "oracle.jdbc.driver.OracleDriver";
    DB_CONNECTION2 = "jdbc:oracle:thin:@10.2.5.23:1521:dbslic";
    DB_USER = "TSR_MOBILE";
    DB_PASSWORD = "TSR_MOBILE";
    

    to

    DB_DRIVER = oracle.jdbc.driver.OracleDriver
    DB_CONNECTION2 = jdbc:oracle:thin:@10.2.5.23:1521:dbslic
    DB_USER = SR_MOBILE
    DB_PASSWORD = TSR_MOBILE
    

    makes the error go away.

    0 讨论(0)
提交回复
热议问题