Thread: problem while running simple java program

problem while running simple java program

From
java unix
Date:
hi,

 when i run a simple program as given below

import java.sql.*;

class PostgreSQLTest {

public static void main (String[] args) {

try{

Class.forName("org.postgresql.Driver");

Connection con =
DriverManager.getConnection("jdbc:postgresql://localhost:5432/test","postgres","roopesh");

Statement stmt = con.createStatement();

ResultSet rs = stmt.executeQuery("select col1 from test");

while(rs.next())

{

System.out.println(rs.getString(1)+"<br>");

}

}catch(Exception e){

System.out.println(e);

}

}

}

when i run it i am getting the following errors

[root@roopesh root]# java PostgreSQLTest
Exception in thread "main" java.lang.InternalError:
unexpected exception during
linking: java.lang.ClassNotFoundException:
javax.net.ssl.SSLSocket
   at 0x40268e17:
java.lang.Throwable.Throwable(java.lang.String)
(/usr/lib/./li
bgcj.so.3)
   at 0x4025bc8e:
java.lang.Error.Error(java.lang.String)
(/usr/lib/./libgcj.so.
3)
   at 0x402691fa:
java.lang.VirtualMachineError.VirtualMachineError(java.lang.St
ring) (/usr/lib/./libgcj.so.3)
   at 0x4025d62e:
java.lang.InternalError.InternalError(java.lang.String)
(/usr/
lib/./libgcj.so.3)
   at 0x4025ad82:
java.lang.ClassLoader.resolveClass0(java.lang.Class)
(/usr/lib
/./libgcj.so.3)
   at 0x4024646c: java.lang.Class.initializeClass()
(/usr/lib/./libgcj.so.3)
   at 0x40244d04:
java.lang.Class.forName(java.lang.String, boolean,
java.lang.C
lassLoader) (/usr/lib/./libgcj.so.3)
   at 0x40244d9f:
java.lang.Class.forName(java.lang.String)
(/usr/lib/./libgcj.s
o.3)
   at 0x403831e7: ffi_call_SYSV
(/usr/lib/./libgcj.so.3)
   at 0x403831a7: ffi_raw_call
(/usr/lib/./libgcj.so.3)
   at 0x402306e8:
_Jv_InterpMethod.continue1(_Jv_InterpMethodInvocation)
(/usr/l
ib/./libgcj.so.3)
   at 0x40230ff4: _Jv_InterpMethod.run(ffi_cif, void,
ffi_raw, _Jv_InterpMethodI
nvocation) (/usr/lib/./libgcj.so.3)
   at 0x4022e504: _Jv_InterpMethod.run_normal(ffi_cif,
void, ffi_raw, void) (/us
r/lib/./libgcj.so.3)
   at 0x4038305c: ?? (??:0)
   at 0x40242dd8:
gnu.gcj.runtime.FirstThread.call_main()
(/usr/lib/./libgcj.so.
3)
   at 0x402ad02d: gnu.gcj.runtime.FirstThread.run()
(/usr/lib/./libgcj.so.3)
   at 0x4024fc4c: _Jv_ThreadRun(java.lang.Thread)
(/usr/lib/./libgcj.so.3)
   at 0x4021c8ac: _Jv_RunMain(java.lang.Class, byte
const, int, byte const, bool
ean) (/usr/lib/./libgcj.so.3)
   at 0x08048910: ?? (??:0)
   at 0x42015574: __libc_start_main
(/lib/tls/libc.so.6)
   at 0x080486c1: ?? (??:0)

the classpath set is as follows

[root@roopesh root]# echo $CLASSPATH
/usr/java/j2sdk1.4.2_07/lib/tools.jar:/usr/java/j2sdk1.4.2_07/jre/lib/rt.jar:/us
r/local/pgsql/pg74.215.jdbc3.jar:/usr/local/pgsql/pg74:/usr/local/pgsql/pg74/org
/postgresql:/usr/local/pgsql


i donot know what is the problem

thank you

Re: problem while running simple java program

From
Antony Paul
Date:
it seems that you are using GNU Java installed in your system(libgcj).
You can test this by giving full path to Sun java compiler instead of
java.


On Mon, 14 Mar 2005 00:27:57 -0800, java unix <javaunix123@gmail.com> wrote:
> hi,
>
>  when i run a simple program as given below
>
> import java.sql.*;
>
> class PostgreSQLTest {
>
> public static void main (String[] args) {
>
> try{
>
> Class.forName("org.postgresql.Driver");
>
> Connection con =
> DriverManager.getConnection("jdbc:postgresql://localhost:5432/test","postgres","roopesh");
>
> Statement stmt = con.createStatement();
>
> ResultSet rs = stmt.executeQuery("select col1 from test");
>
> while(rs.next())
>
> {
>
> System.out.println(rs.getString(1)+"<br>");
>
> }
>
> }catch(Exception e){
>
> System.out.println(e);
>
> }
>
> }
>
> }
>
> when i run it i am getting the following errors
>
> [root@roopesh root]# java PostgreSQLTest
> Exception in thread "main" java.lang.InternalError:
> unexpected exception during
> linking: java.lang.ClassNotFoundException:
> javax.net.ssl.SSLSocket
>    at 0x40268e17:
> java.lang.Throwable.Throwable(java.lang.String)
> (/usr/lib/./li
> bgcj.so.3)
>    at 0x4025bc8e:
> java.lang.Error.Error(java.lang.String)
> (/usr/lib/./libgcj.so.
> 3)
>    at 0x402691fa:
> java.lang.VirtualMachineError.VirtualMachineError(java.lang.St
> ring) (/usr/lib/./libgcj.so.3)
>    at 0x4025d62e:
> java.lang.InternalError.InternalError(java.lang.String)
> (/usr/
> lib/./libgcj.so.3)
>    at 0x4025ad82:
> java.lang.ClassLoader.resolveClass0(java.lang.Class)
> (/usr/lib
> /./libgcj.so.3)
>    at 0x4024646c: java.lang.Class.initializeClass()
> (/usr/lib/./libgcj.so.3)
>    at 0x40244d04:
> java.lang.Class.forName(java.lang.String, boolean,
> java.lang.C
> lassLoader) (/usr/lib/./libgcj.so.3)
>    at 0x40244d9f:
> java.lang.Class.forName(java.lang.String)
> (/usr/lib/./libgcj.s
> o.3)
>    at 0x403831e7: ffi_call_SYSV
> (/usr/lib/./libgcj.so.3)
>    at 0x403831a7: ffi_raw_call
> (/usr/lib/./libgcj.so.3)
>    at 0x402306e8:
> _Jv_InterpMethod.continue1(_Jv_InterpMethodInvocation)
> (/usr/l
> ib/./libgcj.so.3)
>    at 0x40230ff4: _Jv_InterpMethod.run(ffi_cif, void,
> ffi_raw, _Jv_InterpMethodI
> nvocation) (/usr/lib/./libgcj.so.3)
>    at 0x4022e504: _Jv_InterpMethod.run_normal(ffi_cif,
> void, ffi_raw, void) (/us
> r/lib/./libgcj.so.3)
>    at 0x4038305c: ?? (??:0)
>    at 0x40242dd8:
> gnu.gcj.runtime.FirstThread.call_main()
> (/usr/lib/./libgcj.so.
> 3)
>    at 0x402ad02d: gnu.gcj.runtime.FirstThread.run()
> (/usr/lib/./libgcj.so.3)
>    at 0x4024fc4c: _Jv_ThreadRun(java.lang.Thread)
> (/usr/lib/./libgcj.so.3)
>    at 0x4021c8ac: _Jv_RunMain(java.lang.Class, byte
> const, int, byte const, bool
> ean) (/usr/lib/./libgcj.so.3)
>    at 0x08048910: ?? (??:0)
>    at 0x42015574: __libc_start_main
> (/lib/tls/libc.so.6)
>    at 0x080486c1: ?? (??:0)
>
> the classpath set is as follows
>
> [root@roopesh root]# echo $CLASSPATH
> /usr/java/j2sdk1.4.2_07/lib/tools.jar:/usr/java/j2sdk1.4.2_07/jre/lib/rt.jar:/us
> r/local/pgsql/pg74.215.jdbc3.jar:/usr/local/pgsql/pg74:/usr/local/pgsql/pg74/org
> /postgresql:/usr/local/pgsql
>
> i donot know what is the problem
>
> thank you
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
>                http://archives.postgresql.org
>


--
rgds
Antony Paul
http://www.geocities.com/antonypaul24/

Re: problem while running simple java program

From
Oliver Jowett
Date:
java unix wrote:

> [root@roopesh root]# java PostgreSQLTest
> Exception in thread "main" java.lang.InternalError:
> unexpected exception during
> linking: java.lang.ClassNotFoundException:
> javax.net.ssl.SSLSocket

You appear to be using a driver built with SSL (JSSE) support in an
environment that does not provide JSSE.

You need to either add JSSE support (don't know how easy that is) to
your runtime environment, or rebuild the driver from source under the
environment you're actually using, which should disable use of SSL.

-O