sweet dreams sweet dreams - 2 months ago 6x
Java Question

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

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 ?

yes, i was using JDBC, but unable to login to that connection. My url is

username = sys
password = 123456
for the xe or sys connection. Then why can't i login to that connection ?


I am very sorry, I forgot to add that I see another error besides the 1st one, i.e.

SQLException: ORA-28009: connection as SYS should be as SYSDBA or SYSOPER

This is followed by-

Exception in thread "main" java.lang.NullPointerException


If you want to connect as SYS you have to use sys as sysdba

So in your java code try like the following code

    String url = "jdbc:oracle:thin:@//localhost:1521:xe";
    String username = "sys as sysdba";
    String password = "123456";
Connection connection= DriverManager.getConnection(url, username, password);