Re: I can't connect to a database from application
От | Dave Cramer |
---|---|
Тема | Re: I can't connect to a database from application |
Дата | |
Msg-id | 1049223573.1108.116.camel@inspiron.cramers обсуждение исходный текст |
Ответ на | I can't connect to a database from application ("Miguel Angel Martin" <miguelangel.java@ozu.es>) |
Список | pgsql-jdbc |
Miguel, This is the list for the postgres jdbc driver, the driver you are using is the jdxbcon driver. Dave On Mon, 2003-03-31 at 17:21, Miguel Angel Martin wrote: > 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 > > > ---------------------------(end of broadcast)--------------------------- > TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org -- Dave Cramer <Dave@micro-automation.net>
В списке pgsql-jdbc по дате отправления: