wood burning stoves 2.0*
The moose likes JDBC and the fly likes JDBC connection with oracle 10g Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "JDBC connection with oracle 10g" Watch "JDBC connection with oracle 10g" New topic
Author

JDBC connection with oracle 10g

ishani sharma
Greenhorn

Joined: Jun 23, 2010
Posts: 17
hello.
my code:



it throws error:
Exception in thread "main" java.lang.NullPointerException
at edu.trialpackage.databaseConnection.OracleConnect.main(OracleConnect.java:19)



can you please tell me where i am wrong..
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3817

I'm not sure about your approach to connect to DB (I really haven't tried it myself). But I suggest you to use DriverManager (for standalone applications) to get the connection to the DB, which is the preferred method. Check the JDBC tutorial

SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19651
    
  18

Line 19 is "Statement st = con.createStatement();" which can only mean that "con" is null. That means that d.connect("jdbc:oracle:thin:@oracle:8080:STUDENTINFO",p) returns null, which in turn means the URL is wrong.

I second Vijitha's advice to use DriverManager: If there's a problem this will throw an SQLException instead of returning null.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Avi Abrami
Ranch Hand

Joined: Oct 11, 2000
Posts: 1121

For your information, class oracle.jdbc.driver.OracleDriver has been deprecated for many years now.
Its replacement is oracle.jdbc.OracleDriver.

Good Luck,
Avi.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JDBC connection with oracle 10g
 
Similar Threads
JNDI Lookup help in websphere 4.0
The Network Adapter could not establish the connection in jdbc connection
Network could not establish connection in jdbc
creating a WAS client.
Oracle 9i thru WSAD5.0 Problem!!!!!