How do I login to 'xe' connection in Oracle 11g with java code?

前端 未结 3 1062
北荒
北荒 2021-01-21 17:02

I want to make java code that does only this:

Login to the \'xe\' connection in Oracle 11g database. That\'s all. How can do it ?

EDIT: yes, i was using JDBC,

3条回答
  •  不知归路
    2021-01-21 17:17

    You should write the following code :

    private String driver="oracle.jdbc.driver.OracleDriver";
    private String dbURL="jdbc:oracle:thin:@localhost:1521:XE";
    private String dbUserName="sys as sysdba";
    private String dbPassword="123456";
    
    
    try{
    Class.forName(driver);
    con=DriverManager.getConnection(dbURL,dbUserName,dbPassword);
    -----//Rest of your Code//-------
    }catch(Exception e){
    e.printStackTrace();
    }
    

提交回复
热议问题