This week's book giveaways are in the Scala and Android forums.
We're giving away four copies each of Machine Learning Systems: Designs that scale and Xamarin in Action: Creating native cross-platform mobile apps and have the authors on-line!
See this thread and this one for details.
Win a copy of Machine Learning Systems: Designs that scale this week in the Scala forum
or Xamarin in Action: Creating native cross-platform mobile apps in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Newbie: How doy I connect to Oracle Using JDBC  RSS feed

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The next code tells me that ->
" Invalid Oracle URL specified: OracleDriver.connect"
import java.sql.*;
What is wrong???
Please help!!!

[ Edited by Dave to remove smilies and format code ]
[ December 02, 2002: Message edited by: David O'Meara ]
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"TGO",
The Java Ranch has thousands of visitors every week, many with surprisingly similar names. To avoid confusion we have a naming convention, described at http://www.javaranch.com/name.jsp.
We require names to have at least two words, separated by a space, and strongly recommend that you use your full real name. Please edit your profile and select a new name which meets the requirements.
Thanks.
Dave
 
Ranch Hand
Posts: 168
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Third post I found today that has the same problem. (One DB2, One mySQL, now one Oracle).
Doesn't look like you are registering the driver. Only loading the class. Try

The above code works if you import oracle.jdbc.driver.*. If you just put classes12.zip or classes2.zip onto the class path, you will need to do Class.forName().newInstance() and cast that to a Driver.
If you don't register the driver, there is no point in creating an instance of the object.
Also, you might want to declare your Connection variable outside of the try block. So if you catch an error, you will be able to close the connection cleanly in the catch block.
[ December 02, 2002: Message edited by: Michael Zalewski ]
[ December 02, 2002: Message edited by: Michael Zalewski ]
 
Fernando Caceres
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the help but now tells me 'ORA-06401: NETCMN: invalid driver designator'
what is wrong?
 
Michael Zalewski
Ranch Hand
Posts: 168
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OCI is not installed on your webserver. Or it's not properly installed.
Try using the thin client first
 
Fernando Caceres
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks It Works
 
Fernando Caceres
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's working, but this was a connection to a Oracle DB that wasn't (SERVER=DEDICATED) in my TNSNAMES.ORA . NOW I want to connect to a Oracle DB with (SERVER=DEDICATED) but throws this message 'Io exception: The Network Adapter could not establish the connection' , always using JDBC and applets
 
Fernando Caceres
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I found it:
String url1 = "jdbc racle:thin:@(DESCRIPTION = " +
" (ADDRESS_LIST =" +
" (ADDRESS = (PROTOCOL = TCP)(HOST = 1.2.3.4)(PORT = 1521)))" +
" (CONNECT_DATA = " +
" (SID = ORCL) " +
" (SERVER = DEDICATED) ))";

Connection conn =
DriverManager.getConnection (url1, "uid", "pwd");
.....
This works...
 
Let's go to the waterfront with this tiny ad:
Rocket Oven Kickstarter - from the trailboss
https://coderanch.com/t/695773/Rocket-Oven-Kickstarter-trailboss
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!