Hi all,
I'm a java newbie and need help to connect to a postgresql database from NetBeans.
I've managed to register the postgresql driver in service page in NetBeans and establish
a connection to my database, but how should I do it from my code.
This is my code copied from examples on the net:
What am I supposed to enter in Class.forNameprivate void btnOpenDbActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: Connection conn = null; try { // Class.forName("???"); conn = DriverManager.getConnection("jdbc:postgresql:5432//localhost/mapobjectdb", "postgres", "secret"); } catch (SQLException se) { System.out.println("Couldn't connect: print out a stack trace and exit."); se.printStackTrace(); System.exit(1); } if (conn != null) System.out.println("Connected to the database!"); else System.out.println("Couldn't connect"); }
Regards
stab