Re: Newbie SQL question...
Re: Newbie SQL question...
- Subject: Re: Newbie SQL question...
- From: Andreas Monitzer <email@hidden>
- Date: Fri, 14 Dec 2001 22:09:25 +0100
On Friday, December 14, 2001, at 09:38 , Bill Bumgarner wrote:
JDBC does not work via the bridge, there seems to be a bug somewhere.
I wanted to file a bug report for about a year now, but I never took
the time to do it...
(well, once I tried and the bugreporter was down)
I had heard that that was the case... as I do all of my development
with EO under Cocoa using Cocoa/Java, I haven't had a problem.
Cocoa/Java is just Java with some additional class libs, so there is no
problem. I'm talking about accessing it from ObjC.
If you have details or an example, I would be interested in following
up and filing a bugreport...
Example (Foundation tool template) for JDBC/postgresql:
#import <Foundation/Foundation.h>
#import <JavaVM/JavaVM.h>
int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
id date,connection;
NSLog(@"Loading Java VM...");
[[NSJavaVirtualMachine alloc]
initWithClassPath:[[NSJavaVirtualMachine defaultClassPath]
stringByAppendingString:@":/usr/local/pgsql/share/java/postgresql.jar"]]; //
load VM
NSLog(@"done");
date=[[NSClassFromString(@"java.util.Date") alloc] init]; // check
if VM works
NSLog(@"here: %@",date);
// start
NSClassFromString(@"org.postgresql.Driver"); // load Driver
connection=[NSClassFromString(@"java.sql.DriverManager")
getConnection:@"jdbc:postgresql:test" :@"postgres" :@""];
NSLog(@"connection=%@",connection);
[date release];
[pool release];
return 0;
}
Obviously, you need postgres installed to test it:
2001-12-14 22:01:36.861 jdbcTest[16728] Loading Java VM...
2001-12-14 22:01:42.223 jdbcTest[16728] done
2001-12-14 22:01:42.775 jdbcTest[16728] here: Fri Dec 14 22:01:42 CET
2001
Bus error
backtrace in gdb:
#0 0x760e5454 in JVM_GetCPFieldSignatureUTF ()
#1 0x761002b8 in JVM_DoPrivileged ()
#2 0x7614ba60 in JVM_StartThread ()
#3 0x761a6440 in blob ()
#4 0x7610f120 in JVM_GetFieldIxModifiers ()
#5 0x760f2704 in JVM_GetCPMethodModifiers ()
#6 0x760fc370 in JVM_GetCPClassNameUTF ()
#7 0x760fff0c in JVM_DoPrivileged ()
#8 0x7611a164 in JVM_DefineClass ()
#9 0x7611a99c in JVM_FindClassFromClassLoader ()
#10 0x0017d418 in Java_java_lang_Class_forName0 ()
#11 0x2c102648 in ?? ()
#12 0x2c1005cc in ?? ()
#13 0x2c1005cc in ?? ()
#14 0x2c1005cc in ?? ()
#15 0x860d3800 in __vt_9LoopEnter ()
#16 0x760e6ae8 in JVM_ReleaseUTF ()
#17 0x7610c424 in JVM_GetClassNameUTF ()
#18 0x76106060 in JVM_GetMethodIxExceptionsCount ()
#19 0x761e6d2c in jio_vsnprintf ()
#20 0x73ad82c4 in __JAVAMethodInvoke ()
#21 0x73ad88b4 in JAVAStaticMethodInvoke ()
#22 0x73adec40 in _NSInvokeStaticJavaMethod ()
#23 0x73adaf20 in _BRIDGEClassMethodImp ()
#24 0x00002cbc in main (argc=1, argv=0xbffff7a4) at main.m:39
Of course, I could just put that mail into bugreporter. I think I'll do
it if somebody could confirm this bug.
andy