Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within JDBC and Relational Databases
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Tim Cooke
Campbell Ritchie
paul wheaton
Ron McLeod
Devaka Cooray
Sheriffs:
Jeanne Boyarsky
Liutauras Vilda
Paul Clapham
Saloon Keepers:
Tim Holloway
Carey Brown
Piet Souris
Bartenders:
Forum:
JDBC and Relational Databases
Connection to an Oracle database fails
Peter Hammar
Ranch Hand
Posts: 34
posted 14 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
This is in my properties file:
DRIVER=oracle.jdbc.OracleDriver testURL=jdbc:oracle:thin:@194.138.2.166:1521:TEST
try { dbcon = new DbConnection(bundle.getString("DRIVER"),bundle.getString("testURL"),"blaa","blaa"); } catch (java.sql.SQLException ex) { DataCommon.handleError("DataCommon() new DbConnection()", ex, "error", true, true, parent); System.exit(0); } catch (Exception e) { DataCommon.handleError("DataCommon() new DbConnection()", e, "Something is wrong!", true, true, parent); System.exit(0); }
I only get my Something is wrong message. Do I need anything more then the above?
Regards
H
Jan Cumps
Bartender
Posts: 2662
19
I like...
posted 14 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Why don't you print the exception message? "Something is wrong" does not give us a lot of info.
You don't show us where and how you create the connection.
OCUP UML fundamental and ITIL foundation
Peter Hammar
Ranch Hand
Posts: 34
posted 14 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
I get this from printstacktrace:
ava.lang.NullPointerException at pall.data.DbConnection.<init>(DbConnection.java:51) at pall.data.DataCommon.<init>(DataCommon.java:148) at pall.PaLLmeny.<init>(PaLLmeny.java:80) at pallehandel.PaLLehandel.<init>(PaLLehandel.java:45) at pallehandel.PaLLehandel.main(PaLLehandel.java:139)
The connection?
public DbConnection(String _driver, String _url, String _username, String _password) throws Exception { System.out.println(System.getProperty("online")); if (System.getProperty("online").equals("true")) { driver=_driver; url=_url; username=_username; password=_password; Class.forName(driver); System.out.println ("-- connecting to the DB -----"); con = DriverManager.getConnection(url,username,password); System.out.println ("-- connected to the DB! -----"); } } Regards
Jan Cumps
Bartender
Posts: 2662
19
I like...
posted 14 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
The exception tells you at what line of the code the error is.
Note: it is a general
Java
issue (a null pointer exception), not a database issue.
OCUP UML fundamental and ITIL foundation
Peter Hammar
Ranch Hand
Posts: 34
posted 14 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
The application runs fine if I run it in offline mode; no database connection. The errors are thrown when trying to connect to the database.
Line of code that it don't like when in online mode:
cdata = new DataCommon(pallapp);
= at pall.PaLLmeny.<init>(PaLLmeny.java:80)
Thoughts?
Jan Cumps
Bartender
Posts: 2662
19
I like...
posted 14 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Peter Hammar wrote:
...
Thoughts?
Some variable is null, and something in your code does not like that that variable is null.
OCUP UML fundamental and ITIL foundation
Karthik Jayachandran
Ranch Hand
Posts: 93
I like...
posted 14 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
If you are using an IDE like Eclipse, use the debugger. You will know where the exception is throwing.
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Problem with ClassLoader
printStackTrace (); how do I see what it print?
Receiving URL content to applet
How to call servlet do post method from a pojo
Problems connecting weblogic 10.3 to mssql2005
More...