Re: JDBC in PostgreSql for Linux - Mailing list pgsql-general
From | Dmitry Tkach |
---|---|
Subject | Re: JDBC in PostgreSql for Linux |
Date | |
Msg-id | 3EF37319.4020401@openratings.com Whole thread Raw |
In response to | Re: JDBC in PostgreSql for Linux ("Kallol Nandi" <kallol.nandi@indussoft.com>) |
Responses |
Re: JDBC in PostgreSql for Linux
|
List | pgsql-general |
You've got your url wrong - it should be "://" after postrgesql instead of "@" I hope, it helps... Dima Kallol Nandi wrote: >Hi, > >This is the code that I am using for native JDBC Driver to connect to >PostgreSql in Linux. >BTW the version of Postgres is 7.2.2 and the jar file is jdbc7.1-1.2.jar. > >**************************************************************************** >********* >import java.io.*; >import java.sql.*; >import java.util.Properties; >import java.util.Vector; >import org.postgresql.Driver; > >public class JDBCConnection > { >public static void main(String args[]) > { >System.out.println("Testing"); >try > { > String server ="10.100.102.31"; > String port ="5432"; > String database="notes"; > String url="jdbc:postgresql@"+server+":"+port+":"+database; > String userid="postgres"; > String password="postgres"; > Class.forName("org.postgresql.Driver"); > System.out.println("Successful 1 ! "); > Connection con=DriverManager.getConnection(url,userid,password); > Statement stmt = con.createStatement(); > ResultSet rset = stmt.executeQuery ("Select count(*) as c from >testtable"); > rset.next(); > int currval = rset.getInt("c"); > System.out.println("Successful 2 ! "); > System.out.println(currval); > con.close(); > } >catch(Exception ex) { >System.out.println("Error problem!"); >System.out.println(ex.getMessage()); >ex.printStackTrace(); >return; > } > } >} > > > > >**************************************************************************** >********* >I am getting the error mentioned i my earlier mail in the following line : > > Connection con=DriverManager.getConnection(url,userid,password); > >The error is : >**************************************************************************** >** > I get the following error : > Driver not found for URL: jdbc:postgresql@10.100.102.31:5432:notes > java.sql.SQLException: Driver not found for URL: >jdbc:postgresql@10.100.102.31:5432:notes > at 0x4028115f: java.lang.Throwable.Throwable(java.lang.String) >(/usr/lib/libgcj.so.3) > at 0x402740d2: java.lang.Exception.Exception(java.lang.String) >(/usr/lib/libgcj.so.3) > at 0x40316294: java.sql.SQLException.SQLException(java.lang.String, >java.lang.String, int) (/usr/lib/libgcj.so.3) > at 0x40316244: java.sql.SQLException.SQLException(java.lang.String) >(/usr/lib/libgcj.so.3) > at 0x40316102: java.sql.DriverManager.getConnection(java.lang.String, >java.util.Properties) (/usr/lib/libgcj.so.3) > at 0x4031603a: java.sql.DriverManager.getConnection(java.lang.String, >java.lang.String, java.lang.String) (/usr/lib/libgcj.so.3) > at 0x4039d347: ffi_call_SYSV (/usr/lib/libgcj.so.3) > at 0x4039d307: ffi_raw_call (/usr/lib/libgcj.so.3) > at 0x40248528: _Jv_InterpMethod.continue1(_Jv_InterpMethodInvocation) >(/usr/lib/libgcj.so.3) > at 0x40248e34: _Jv_InterpMethod.run(ffi_cif, void, ffi_raw, >_Jv_InterpMethodInvocation) (/usr/lib/libgcj.so.3) > at 0x40246424: _Jv_InterpMethod.run_normal(ffi_cif, void, ffi_raw, void) >(/usr/lib/libgcj.so.3) > at 0x4039d1bc: ?? (??:0) > at 0x4025b308: gnu.gcj.runtime.FirstThread.call_main() >(/usr/lib/libgcj.so.3) > at 0x402c60b1: gnu.gcj.runtime.FirstThread.run() (/usr/lib/libgcj.so.3) > at 0x40267fdc: _Jv_ThreadRun(java.lang.Thread) (/usr/lib/libgcj.so.3) > at 0x4023478c: _Jv_RunMain(java.lang.Class, byte const, int, byte const, >boolean) (/usr/lib/libgcj.so.3) > at 0x08048900: ?? (??:0) > at 0x420158d4: ?? (??:0) > at 0x080486c1: ?? (??:0) >**************************************************************************** >********* > > >Thanks and Regards, >Kallol. > >-----Original Message----- >From: pgsql-general-owner@postgresql.org >[mailto:pgsql-general-owner@postgresql.org]On Behalf Of Thomas Kellerer >Sent: Friday, June 20, 2003 4:12 PM >To: pgsql-general@postgresql.org >Subject: Re: [GENERAL] JDBC in PostgreSql for Linux > > > >Kallol Nandi schrieb: > > >>I am running a Java application on Linux which connects to the Postgresql >> >> >on Linux using jdbcodbc bridge. > > >>But this is the error I am getting : >> >>I have also tried running a Java application using the Native JDBC Driver. >>I get the following error : >>Driver not found for URL: jdbc:postgresql@10.100.102.31:5432:notes >>java.sql.SQLException: Driver not found for URL: >> >> >jdbc:postgresql@10.100.102.31:5432:notes > > >> at 0x4028115f: java.lang.Throwable.Throwable(java.lang.String) >> >> >(/usr/lib/libgcj.so.3) > > >> at 0x402740d2: java.lang.Exception.Exception(java.lang.String) >> >> >(/usr/lib/libgcj.so.3) > > >> at 0x40316294: java.sql.SQLException.SQLException(java.lang.String, >> >> >java.lang.String, int) (/usr/lib/libgcj.so.3) > > >> at 0x40316244: java.sql.SQLException.SQLException(java.lang.String) >> >> >(/usr/lib/libgcj.so.3) > > >> at 0x40316102: java.sql.DriverManager.getConnection(java.lang.String, >> >> >java.util.Properties) (/usr/lib/libgcj.so.3) > > >> at 0x4031603a: java.sql.DriverManager.getConnection(java.lang.String, >> >> >java.lang.String, java.lang.String) (/usr/lib/libgcj.so.3) > > >> at 0x4039d347: ffi_call_SYSV (/usr/lib/libgcj.so.3) >> at 0x4039d307: ffi_raw_call (/usr/lib/libgcj.so.3) >> at 0x40248528: _Jv_InterpMethod.continue1(_Jv_InterpMethodInvocation) >> >> >(/usr/lib/libgcj.so.3) > > >> at 0x40248e34: _Jv_InterpMethod.run(ffi_cif, void, ffi_raw, >> >> >_Jv_InterpMethodInvocation) (/usr/lib/libgcj.so.3) > > >> at 0x40246424: _Jv_InterpMethod.run_normal(ffi_cif, void, ffi_raw, >> >> >void) (/usr/lib/libgcj.so.3) > > >> at 0x4039d1bc: ?? (??:0) >> at 0x4025b308: gnu.gcj.runtime.FirstThread.call_main() >> >> >(/usr/lib/libgcj.so.3) > > >> at 0x402c60b1: gnu.gcj.runtime.FirstThread.run() (/usr/lib/libgcj.so.3) >> at 0x40267fdc: _Jv_ThreadRun(java.lang.Thread) (/usr/lib/libgcj.so.3) >> at 0x4023478c: _Jv_RunMain(java.lang.Class, byte const, int, byte >> >> >const, boolean) (/usr/lib/libgcj.so.3) > > >> at 0x08048900: ?? (??:0) >> at 0x420158d4: ?? (??:0) >> at 0x080486c1: ?? (??:0) >> >>Please do reply me asap. >> >> >> >I have no real experience with Linux but as far as I know the JdbcOdbc >bridge is only distributed with the JDK for windows. > >I'd suggest you stick with the native JDBC driver. >The second error indicates an error with your classpath. Is there a >reason why you don't use the SUN JDK for development? Does the GNU >compiler support Class.forName() (which is the usual way of registering >the drive) in the meantime? > >Without your code, it's really hard to tell where your error is. > >Thomas > > > >---------------------------(end of broadcast)--------------------------- >TIP 4: Don't 'kill -9' the postmaster > > >---------------------------(end of broadcast)--------------------------- >TIP 5: Have you checked our extensive FAQ? > > http://www.postgresql.org/docs/faqs/FAQ.html > >
pgsql-general by date: