I can't connect to a database from application

Поиск
Список
Период
Сортировка
От Miguel Angel Martin
Тема I can't connect to a database from application
Дата
Msg-id web-201221404@ozu.es
обсуждение исходный текст
Ответы Re: I can't connect to a database from application  (Dave Cramer <Dave@micro-automation.net>)
Список pgsql-jdbc
I can't connect to a database from application but yes
from IDE!.

I use: Cygwin-postgresql 7.3.2   Win98  Netbeans 3.4  and
JDK 1.4

I Launch postgresql with the -i option to enable TCP/IP
connections.
No problem to connect to de database by the database
option of the Runtime panel in Netbeans.  I can access all
the tables, etc.  But, I can't  connect to the database
from an application (inside Netbeans).   The source, to
check the database access, is:

import java.sql.*;
public class postgres {
     public static void main(String[] args) {
         System.out.println("trying...");
         try {
             String url = new
                 String("jdbc:postgresql:net//localhost:5432/basicportal");
             String usr = new String("xxxx");
             String pwd = new String(""); //postgres
usr/password
             System.out.println("finding driver...");
             Class.forName("org.sourceforge.jxdbcon.JXDBConDriver");
             System.out.println("creating
driverManager...");
             Connection db =
DriverManager.getConnection(url,usr,pwd);
             System.out.println("creating statement...");
             Statement st = db.createStatement();
             System.out.println("executing query...");
             ResultSet rs = st.executeQuery("select * from
base_content");
             System.out.println("looping data...");
             while(rs.next()) {
                 System.out.print("Column 1 returned ");
                 System.out.println(rs.getString(1));
             }
             System.out.println("loop finished, closing
connection");
             rs.close();
             st.close();
         }
         catch( Exception e) {
             System.out.println("Exception encountered: "
+ e);
         }
     }
}


And this is the output of the Output Window:
trying...
finding driver...
creating driverManager...
Exception encountered: java.lang.NullPointerException

And the output of postgre in the Cygwin Window:
"LOG:  pq_recvbuf: unexpected EOF on client connection"


I'd put posgresql.jar  in
netbeans\lib\ext
myapplication\WEB-INF\lib

and, later, in
tomcat404\classes
netbeans\tomcat404\lib

Can anybody help me?

Thanks !


Miguel A. Martin
Malaga - Spain
--------------------------------------------------
Nuevo Depósito a 1 mes 6% TAE, contrátalo:
http://ingdirect.ozu.es
--------------------------------------------------
Correo enviado desde http://www.ozu.es


В списке pgsql-jdbc по дате отправления:

Предыдущее
От: Dave Cramer
Дата:
Сообщение: Re: setObject() throw exception message: "The table for
Следующее
От: "Henri Chen"
Дата:
Сообщение: setObject() throw exception message: "The table for java.util.Date is not in the database. ..."