Re: Problem with connecting to postgres using jdbc7.0-1.2.jar
От | Rene Pijlman |
---|---|
Тема | Re: Problem with connecting to postgres using jdbc7.0-1.2.jar |
Дата | |
Msg-id | bknd2u0r6k1rmc4872bnj5uotacetlqc4d@4ax.com обсуждение исходный текст |
Ответ на | Problem with connecting to postgres using jdbc7.0-1.2.jar (Peter Adamek <peter.adamek@utoronto.ca>) |
Список | pgsql-jdbc |
On Mon, 24 Dec 2001 00:33:41 -0500, you wrote: >This may be a rookie mistake. [...] > try {Class.forName("org.postgresql.Driver");} [...] > try {db = >DriverManager.getConnection("jdbc:postgresql:peter","padamek","");} > catch (SQLException e) {} > } At first glance this looks OK (if you can logon using this connect string and username, and without a password). The most common rookie mistake is not to configure the PostgreSQL server to accept incoming connections on a TCP/IP socket. Documentation is available on http://jdbc.postgresql.org/doc.html, http://www.postgresql.org/idocs/index.php?jdbc.html#JDBC-PREPARE, http://www.fankhausers.com/postgresql/jdbc/ and http://www.fankhausers.com/tomcat/jdbc/. >When I compile it with the verbose javac option, here is what I get: I don't see a problem in this log. >When I try to run the servlet, I get the following error (it seems like >the database connection is not being made - db is assigned a null >value): I don't see any mention of 'db' or PostgreSQL in this exception stack trace. >It seems strage to me that if I >change the driver name that reads >Class.forName("org.postgresql.Driver"), I get no errors when I compile. >I could change it to Class.forName("heyYou") and it would still compile >with no errors. That's normal. Class.forName() is a runtime statement. You would get another exception if this class can't be found at runtime. >The other thing that seems strange is that if you look >at the verbose output of my javac call, it seems like the sql >DriverManagement and ResultSet classes are coming from the Java JDK >1.3.1 install and not the postgres 7.0-1.2 JDBC java driver that was >supplied from postgres.org. The JDK provides the java.sql interfaces, the driver implements them. Have you tried to connect to the same PostgreSQL database from the same client with a simple 'hello world' application that does the same class.forName() and uses the same connect string? Regards, René Pijlman <rene@lab.applinet.nl>
В списке pgsql-jdbc по дате отправления: