hello friends
i'm work with django. but i create the reports in java
how to link java and postgresql.please help me...
i'm try following code but driver found not connect with db what do
to....
import java.sql.DriverManager;
import java.sql.Connection;
import java.sql.SQLException;
public class Example1 {
public static void main(String[] argv) {
System.out.println("Checking if Driver is registered with
DriverManager.");
try {
Class.forName("org.postgresql.Driver");
} catch (ClassNotFoundException cnfe) {
System.out.println("Couldn't find the driver!");
System.out.println("Let's print a stack trace, and exit.");
cnfe.printStackTrace();
System.exit(1);
}
System.out.println("Registered the driver ok, so let's make a
connection.");
Connection c = null;
try {
System.out.println("Connected before...");
//c = DriverManager.getConnection("jdbc:postgresql://localhost/
database","username", "password");
c = DriverManager.getConnection("jdbc:postgresql://localhost:8000/
database","balaji","test");
System.out.println("------Connected after...Now creating a
statement");
} catch (SQLException se) {
System.out.println("Couldn't connect: print out a stack trace and
exit.");
se.printStackTrace();
System.exit(1);
}
if (c != null)
System.out.println("Hooray! We connected to the database!");
else
System.out.println("We should never get here.");
}
}
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---