Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

getting connection

 
steffy john
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I do have Personal oracle installed in my machine.
Now I log in that using scott and tiger.
I want to get connected to the same using the foillowing code:
con = DriverManager.getConnection("jdbc racle:thin:@machinename:1521:","scott","tiger");
But I am not getting a connection.
Can anyone correct me ?
Steff
 
Marcos Maia
Ranch Hand
Posts: 977
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
java.util.Properties props = new java.util.Properties();
props.put("user", "your_user");
props.put("password", "the_password");
java.sql.Driver d = (java.sql.Driver)Class.forName("oracle.jdbc.driver.OracleD
river").newInstance();
java.sql.Connection conn = d.connect("jdbc racle:thin:@HOST_ADRESS:PORT:ORACLE",
p
rops);
OR:

Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
java.sql.Connection conn =
Driver.connect("jdbc racle:thin:@HOST_ADRESS:PORT:ORACLE", "user", "password");
OR:

java.util.Properties props = new java.util.Properties();
props.put("user", "your_username");
props.put("password", "the_password");
Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
java.sql.Connection conn =
Driver.connect("jdbc racle:thin:@HOST_ADRESS:PORT:ORACLE", props);
regards.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic