How to Connect Oracle Database (sysdba) by Java code

 public class ConnectSysdba {
 public static void main(String[] args) throws Exception {
 String driver = "oracle.jdbc.Driver";
 String url = "jdbc:oracle:thin:@localhost:1521:XE";
 Connection con = null;
 // load jdbc driver
 // connection info
 Properties info = new Properties();
 info.put("user", "sys");
 info.put("password", "oracle");
 info.put("internal_logon", "sysdba");
 // connect as sysdba
 con = DriverManager.getConnection(url, info);
 // check username
 String sql = "select user from dual";
 PreparedStatement ps = con.prepareStatement(sql);
 ResultSet rs = ps.executeQuery();;
 System.out.println("Username = " + rs.getString(1));


  1. Thanks for this useful article. It is really very helpful.

  2. You are welcome my friend.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: