Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
Java
PostgreSQL/Eclipse/Tomcat - How to connect to DB?
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Thomas Hoheneder, post: 587797"] Define "do not compile well". Do you get a compilation error? If so, In eclipse it's the standard behaviour that code compiles always "automaticallly" when the source file is saved. When something could not be compiled well or could not be recognized as correct code, then Eclipse underlines the appropriate section in red colour. This I have meant by "does not compile well". Within the installation process of Postgres 8.0 two sample databases are automatically created and they are named "template0" and "template1". To test my db connection, I first wanted to connect to "template1" before creating an own database. In the meantime I got some information from Eclipse when moving the mouse cursor above the red underlined code. Eclipse showed me a tool tip where it said "Unhandeled exception type ClassNotFoundException" at the forName() call and "Unhandeled exception type SQLException" at the getConnection() call. This brought me to the idea that I should use a try catch block for both instructions and catch the appropriate exceptions. And - this was the solution. Now it works. And now I did it with an own database named "registration". But nevertheless thank you very much for your help. The code now is: try { Class.forName("org.postgresql.Driver"); Connection con = DriverManager.getConnection("" + "jdbc:postgresql://127.0.0.1:5432/registration", "<username>", "<password>"); } catch (ClassNotFoundException cnfe) { System.out.println(cnfe.toString()); } catch (SQLException sqle) { System.out.println(sqle.toString()); } Nice greetings from Thomas [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
Java
PostgreSQL/Eclipse/Tomcat - How to connect to DB?
Top