Home » Newcomers » Newcomers » Conflict between JDBC and SWT in Eclipse 3.0
Conflict between JDBC and SWT in Eclipse 3.0 [message #77057] |
Sat, 11 June 2005 22:50  |
Eclipse User |
|
|
|
Hi
I've got a test program that uses JDBC to connect to an Oracle database.
That portion of the program works fine on its own (it will return valid
results from a database query).
Once I add SWT code to the program the JDBC portion stops working. Here
are the details :
a) add C:\Program
Files\eclipse3.0.1\plugins\org.eclipse.swt.win32_3.0.1\ws\wi n32\swt.jar
to the libraries for the project
b)add -Djava.library.path="c:\Program
Files\eclipse3.0.1\plugins\org.eclipse.swt.win32_3.0.1\os\wi n32\x86
to the VM Args in the configuration dialog
c) import org.eclipse.swt.widgets.*;
import org.eclipse.swt.*;
in the Test class's source file
d) add the following simple swt test code to the same Main method of the
Test class that has the jdbc code:
Display display = new Display();
Shell shell = new Shell(display);
shell.setSize(300,200);
Label label = new Label(shell, SWT.CENTER);
label.setText("No worries!");
label.setBounds(shell.getClientArea());
shell.open();
while (!shell.isDisposed())
{
if(!display.readAndDispatch())
display.sleep();
}
display.dispose();
When I run the main method of the Test class which now contains the JDBC
and SWT code, the following problem shows up in the Eclipse console. (By
the way the Oracle JDBC library is ojdbc14.jar):
java.lang.UnsatisfiedLinkError: no ocijdbc9 in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1517)
at java.lang.Runtime.loadLibrary0(Runtime.java:788)
at java.lang.System.loadLibrary(System.java:834)
at oracle.jdbc.oci8.OCIDBAccess.logon(OCIDBAccess.java:262)
at oracle.jdbc.driver.OracleConnection.<init>(OracleConnection.java:346)
at
oracle.jdbc.driver.OracleDriver.getConnectionInstance(Oracle Driver.java:468)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:31 4)
at java.sql.DriverManager.getConnection(DriverManager.java:512)
at java.sql.DriverManager.getConnection(DriverManager.java:171)
at Test.main(Test.java:34)
Either I'm ignorant of what to do, or the reference to the SWT java
library path in the VM Args ( b, above) is making Eclipse confused.
Any useful help in getting SWT and JDBC to coexist would be greatly
appreciated!
Thanks in advance.
-Lenny Wintfeld
|
|
| | | | |
Re: Conflict between JDBC and SWT in Eclipse 3.0 [message #77494 is a reply to message #77109] |
Mon, 13 June 2005 12:48   |
Eclipse User |
|
|
|
Originally posted by: lwintfeld.libertycorner.net
Darin,
I don't know who you are, other than that you've been kind enough to reply
to my problem on the eclipse newcomer newsgroup. If you could take the time
to pursue this just a bit further, I'd appreciate it.
The solution behind door number two did not work.
I've tried probably 20 launch configurations all of which put different
paths to the right of the = in the VM Args: -Djava.library.path=<paths go
here> .
I suspected that there might be a problem parsing a path that had a space
character in it
(like c:\Program <sp> Files\....), even though I enclosed the paths in
double quotes. So I copied some directory trees wholesale to a subfolder
that had no space characters and tried using the SWT JNI library from there.
No joy.
I tried changing the order of the paths to the various libraries listed in
the VM args. No joy.
Tried a trailing \ before each ;. No joy.
I finally was able to make the program run using both the swt and jdbc
libraries by bypassing the need to specify a path to the JNI library code in
the launch configuration. I did this by a) MOVING the swt jni library
(swt-win32-3063.dll) from where it was (and where it belongs) in the
...\eclipse\plugins\... subtree into the ...\java\bin... directory, and b)
not specifying a java.lbrary.path to the VM in the launch configuration.
Here's as specific as I can get:
The setup I want to run is literally as follows
JRE System Library in: C:\j2sdk1.4.2_07\jre\lib\....
JDBC Library in: C:\KledarasTechnologies\lib\ojdbc14.jar
SWT Library in:
C:\eclipse3.0.1\plugins\org.eclipse.swt.win32_3.0.1\ws\win32 \swt.jar
SWT JNI Library in:
C:\eclipse3.0.1\plugins\org.eclipse.swt.win32_3.0.1\0s\win32 \x86\swt-win32-3063.dll
<-PROBLEM HERE
But since I can't seem to convince the JVM to get the JNI library
"swt-win32-3063.dll" at the above path by specifying that path in the VM
args of the launch configuration I'm forced to use the following setup:
JRE System Library in: C:\j2sdk1.4.2_07\jre\lib\....
JDBC Library in: C:\KledarasTechnologies\lib\ojdbc14.jar
SWT Library in:
C:\eclipse3.0.1\plugins\org.eclipse.swt.win32_3.0.1\ws\win32 \swt.jar
SWT JNI Library in: C:\j2sdk1.4.2_07\jre\bin\ <-CLUNKY FIX HERE
Finally, I reiterate the original problem: I can use the JDBC "ojdbc14.jar"
library with no problem, by itself in mye Test class. I can use the SWT
library / SWT JNI library by itself in my Test class with no problem. But
they don't play together.
I hate the idea of punting around what appears to be a problem with Eclipse
(by putting the SWT JNI library in a spot where it really doesn't belong).
I'm a newcomer to Eclipse, so it's more likely that I'm the one doing
something wrong, not Eclipse. But I just don't see what it could be at this
point!
I'd greatly appreciate any additional ideas. Do you think it COULD be
Eclipse?
TIA.
-Lenny
"Darin Swanson" <Darin_Swanson@us.ibm.com> wrote in message
news:d8hqeh$cbe$1@news.eclipse.org...
> Door #2 and with Windows it is a semicolon
>
> Darins
>
>
> "Lenny Wintfeld" <lennyw@comcast.net> wrote in message
> news:d8hhap$3rn$1@news.eclipse.org...
>> Thanks Darin. What's the syntax?
>>
>> One "-Djava.library.path =" for each path? e.g -Djava.library.path =
>> c:\mypath1 -Djava.library.path=e:\thispath2 -Djava.library.path =
>> c:\thatpath3... etc.
>>
>> Or semicolons separating each path on the right side of the equals, as is
>> found in global path declarations in DOS/Windows
>> (e.g. -Djava.library.path=c:\myypath1;e:thispath2;c:thatpath3... etc.)
>>
>> Or something else?
>>
>> Maybe soon I'll be on the right path :-)
>>
>> -Lenny
>>
>> Darin Swanson wrote:
>>> You are setting your entire java.library.path to be just the SWT
>>> directory.
>>> Add the ojdbc14.jar to your java.library.path as well (and / or all the
>>> other library paths you may need)
>>>
>>> HTH
>>> Darins
>>>
>>> "Lenny Wintfeld" <lennyw@comcast.net> wrote in message
>>> news:d8g7t2$ve$1@news.eclipse.org...
>>>
>>>>Hi
>>>>
>>>>I've got a test program that uses JDBC to connect to an Oracle database.
>>>>That portion of the program works fine on its own (it will return valid
>>>>results from a database query).
>>>>
>>>>Once I add SWT code to the program the JDBC portion stops working. Here
>>>>are the details :
>>>>
>>>>a) add C:\Program
>>>> Files\eclipse3.0.1\plugins\org.eclipse.swt.win32_3.0.1\ws\wi n32\swt.jar
>>>>to the libraries for the project
>>>>
>>>>b)add -Djava.library.path="c:\Program
>>>> Files\eclipse3.0.1\plugins\org.eclipse.swt.win32_3.0.1\os\wi n32\x86
>>>>to the VM Args in the configuration dialog
>>>>
>>>>c) import org.eclipse.swt.widgets.*;
>>>> import org.eclipse.swt.*;
>>>>in the Test class's source file
>>>>
>>>>d) add the following simple swt test code to the same Main method of the
>>>>Test class that has the jdbc code:
>>>>
>>>> Display display = new Display();
>>>> Shell shell = new Shell(display);
>>>> shell.setSize(300,200);
>>>> Label label = new Label(shell, SWT.CENTER);
>>>> label.setText("No worries!");
>>>> label.setBounds(shell.getClientArea());
>>>> shell.open();
>>>> while (!shell.isDisposed())
>>>> {
>>>> if(!display.readAndDispatch())
>>>> display.sleep();
>>>> }
>>>> display.dispose();
>>>>
>>>>
>>>>
>>>>When I run the main method of the Test class which now contains the JDBC
>>>>and SWT code, the following problem shows up in the Eclipse console. (By
>>>>the way the Oracle JDBC library is ojdbc14.jar):
>>>>
>>>>java.lang.UnsatisfiedLinkError: no ocijdbc9 in java.library.path
>>>> at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1517)
>>>> at java.lang.Runtime.loadLibrary0(Runtime.java:788)
>>>> at java.lang.System.loadLibrary(System.java:834)
>>>> at oracle.jdbc.oci8.OCIDBAccess.logon(OCIDBAccess.java:262)
>>>> at
>>>> oracle.jdbc.driver.OracleConnection.<init>(OracleConnection.java:346)
>>>> at
>>>> oracle.jdbc.driver.OracleDriver.getConnectionInstance(Oracle Driver.java:468)
>>>> at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:31 4)
>>>> at java.sql.DriverManager.getConnection(DriverManager.java:512)
>>>> at java.sql.DriverManager.getConnection(DriverManager.java:171)
>>>> at Test.main(Test.java:34)
>>>>
>>>>Either I'm ignorant of what to do, or the reference to the SWT java
>>>>library path in the VM Args ( b, above) is making Eclipse confused.
>>>>
>>>>
>>>>Any useful help in getting SWT and JDBC to coexist would be greatly
>>>>appreciated!
>>>>
>>>>Thanks in advance.
>>>>
>>>>-Lenny Wintfeld
>>>
>>>
>
|
|
|
Re: Conflict between JDBC and SWT in Eclipse 3.0 SOLVED [message #77571 is a reply to message #77494] |
Mon, 13 June 2005 15:15  |
Eclipse User |
|
|
|
Originally posted by: lwintfeld.libertycorner.net
Darin
After reading your last reply (below) and then reading the Help for the
"Environment" tab I did something between an Aha and a Duh.
I added the Windows system global environment PATH to the environment
tab and then prepended the path to the JNI dlls to the start of that
path. Now my test app runs with all libraries where they're supposed to
be!
BTW. By poking around a bit, I see that the text of the PATH in the Eclipse
environment tab, even though it comes from the system global path,
stands by itself, and edits to it are not reflected in the system global
path.... very nice.
Thanks very much. I appreciate you sticking with me on this.
-Lenny
-----Original Message-----
From: Darin Swanson [mailto:Darin_Swanson@us.ibm.com]
Sent: Monday, June 13, 2005 1:29 PM
To: Lenny Wintfeld
Subject: Re: Conflict between JDBC and SWT in Eclipse 3.0
Lenny,
I think that problem is that when you set the java.library.path to
something that is much less than what it would be by default.
The java.library.path is usually quite a large beast...picks up all the
goodies from your system path.
Try just adding to your PATH variable via the environment tab for you
launch configuration
On the Environment tab, click Select
Select "Path"
Click Edit
Add the location of the SWT libraries to the path
Let me know if it works :-)
Darins
"Lenny Wintfeld" <lwintfeld@libertycorner.net> wrote in message
news:d8kdd6$5uc$1@news.eclipse.org...
> Darin,
>
>
>
> I don't know who you are, other than that you've been kind enough to reply
> to my problem on the eclipse newcomer newsgroup. If you could take the
> time to pursue this just a bit further, I'd appreciate it.
>
>
>
> The solution behind door number two did not work.
>
>
>
> I've tried probably 20 launch configurations all of which put different
> paths to the right of the = in the VM Args: -Djava.library.path=<paths go
> here> .
>
>
>
> I suspected that there might be a problem parsing a path that had a space
> character in it
>
> (like c:\Program <sp> Files\....), even though I enclosed the paths in
> double quotes. So I copied some directory trees wholesale to a subfolder
> that had no space characters and tried using the SWT JNI library from
> there. No joy.
>
>
>
> I tried changing the order of the paths to the various libraries listed in
> the VM args. No joy.
>
>
>
> Tried a trailing \ before each ;. No joy.
>
>
>
> I finally was able to make the program run using both the swt and jdbc
> libraries by bypassing the need to specify a path to the JNI library code
> in the launch configuration. I did this by a) MOVING the swt jni library
> (swt-win32-3063.dll) from where it was (and where it belongs) in the
> ..\eclipse\plugins\... subtree into the ...\java\bin... directory, and b)
> not specifying a java.lbrary.path to the VM in the launch configuration.
>
>
>
>
>
> Here's as specific as I can get:
>
>
>
> The setup I want to run is literally as follows
>
>
>
> JRE System Library in: C:\j2sdk1.4.2_07\jre\lib\....
>
> JDBC Library in: C:\KledarasTechnologies\lib\ojdbc14.jar
>
> SWT Library in:
> C:\eclipse3.0.1\plugins\org.eclipse.swt.win32_3.0.1\ws\win32 \swt.jar
>
> SWT JNI Library in:
> C:\eclipse3.0.1\plugins\org.eclipse.swt.win32_3.0.1\0s\win32 \x86\swt-win32-3063.dll
> <-PROBLEM HERE
>
> But since I can't seem to convince the JVM to get the JNI library
> "swt-win32-3063.dll" at the above path by specifying that path in the VM
> args of the launch configuration I'm forced to use the following setup:
>
>
>
> JRE System Library in: C:\j2sdk1.4.2_07\jre\lib\....
>
> JDBC Library in: C:\KledarasTechnologies\lib\ojdbc14.jar
>
> SWT Library in:
> C:\eclipse3.0.1\plugins\org.eclipse.swt.win32_3.0.1\ws\win32 \swt.jar
>
> SWT JNI Library in: C:\j2sdk1.4.2_07\jre\bin\ <-CLUNKY FIX HERE
>
>
>
> Finally, I reiterate the original problem: I can use the JDBC
> "ojdbc14.jar" library with no problem, by itself in mye Test class. I can
> use the SWT library / SWT JNI library by itself in my Test class with no
> problem. But they don't play together.
>
>
>
> I hate the idea of punting around what appears to be a problem with
> Eclipse (by putting the SWT JNI library in a spot where it really doesn't
> belong). I'm a newcomer to Eclipse, so it's more likely that I'm the one
> doing something wrong, not Eclipse. But I just don't see what it could be
> at this point!
>
>
>
> I'd greatly appreciate any additional ideas. Do you think it COULD be
> Eclipse?
>
>
>
> TIA.
>
>
>
> -Lenny
>
>
>
>
>
> "Darin Swanson" <Darin_Swanson@us.ibm.com> wrote in message
> news:d8hqeh$cbe$1@news.eclipse.org...
>> Door #2 and with Windows it is a semicolon
>>
>> Darins
>>
>>
>> "Lenny Wintfeld" <lennyw@comcast.net> wrote in message
>> news:d8hhap$3rn$1@news.eclipse.org...
>>> Thanks Darin. What's the syntax?
>>>
>>> One "-Djava.library.path =" for each path? e.g -Djava.library.path =
>>> c:\mypath1 -Djava.library.path=e:\thispath2 -Djava.library.path =
>>> c:\thatpath3... etc.
>>>
>>> Or semicolons separating each path on the right side of the equals, as
>>> is found in global path declarations in DOS/Windows
>>> (e.g. -Djava.library.path=c:\myypath1;e:thispath2;c:thatpath3... etc.)
>>>
>>> Or something else?
>>>
>>> Maybe soon I'll be on the right path :-)
>>>
>>> -Lenny
>>>
>>> Darin Swanson wrote:
>>>> You are setting your entire java.library.path to be just the SWT
>>>> directory.
>>>> Add the ojdbc14.jar to your java.library.path as well (and / or all the
>>>> other library paths you may need)
>>>>
>>>> HTH
>>>> Darins
>>>>
>>>> "Lenny Wintfeld" <lennyw@comcast.net> wrote in message
>>>> news:d8g7t2$ve$1@news.eclipse.org...
>>>>
>>>>>Hi
>>>>>
>>>>>I've got a test program that uses JDBC to connect to an Oracle
>>>>>database.
>>>>>That portion of the program works fine on its own (it will return valid
>>>>>results from a database query).
>>>>>
>>>>>Once I add SWT code to the program the JDBC portion stops working. Here
>>>>>are the details :
>>>>>
>>>>>a) add C:\Program
>>>>> Files\eclipse3.0.1\plugins\org.eclipse.swt.win32_3.0.1\ws\wi n32\swt.jar
>>>>>to the libraries for the project
>>>>>
>>>>>b)add -Djava.library.path="c:\Program
>>>>> Files\eclipse3.0.1\plugins\org.eclipse.swt.win32_3.0.1\os\wi n32\x86
>>>>>to the VM Args in the configuration dialog
>>>>>
>>>>>c) import org.eclipse.swt.widgets.*;
>>>>> import org.eclipse.swt.*;
>>>>>in the Test class's source file
>>>>>
>>>>>d) add the following simple swt test code to the same Main method of
>>>>>the
>>>>>Test class that has the jdbc code:
>>>>>
>>>>> Display display = new Display();
>>>>> Shell shell = new Shell(display);
>>>>> shell.setSize(300,200);
>>>>> Label label = new Label(shell, SWT.CENTER);
>>>>> label.setText("No worries!");
>>>>> label.setBounds(shell.getClientArea());
>>>>> shell.open();
>>>>> while (!shell.isDisposed())
>>>>> {
>>>>> if(!display.readAndDispatch())
>>>>> display.sleep();
>>>>> }
>>>>> display.dispose();
>>>>>
>>>>>
>>>>>
>>>>>When I run the main method of the Test class which now contains the
>>>>>JDBC and SWT code, the following problem shows up in the Eclipse
>>>>>console. (By the way the Oracle JDBC library is ojdbc14.jar):
>>>>>
>>>>>java.lang.UnsatisfiedLinkError: no ocijdbc9 in java.library.path
>>>>> at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1517)
>>>>> at java.lang.Runtime.loadLibrary0(Runtime.java:788)
>>>>> at java.lang.System.loadLibrary(System.java:834)
>>>>> at oracle.jdbc.oci8.OCIDBAccess.logon(OCIDBAccess.java:262)
>>>>> at
>>>>> oracle.jdbc.driver.OracleConnection.<init>(OracleConnection.java:346)
>>>>> at
>>>>> oracle.jdbc.driver.OracleDriver.getConnectionInstance(Oracle Driver.java:468)
>>>>> at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:31 4)
>>>>> at java.sql.DriverManager.getConnection(DriverManager.java:512)
>>>>> at java.sql.DriverManager.getConnection(DriverManager.java:171)
>>>>> at Test.main(Test.java:34)
>>>>>
>>>>>Either I'm ignorant of what to do, or the reference to the SWT java
>>>>>library path in the VM Args ( b, above) is making Eclipse confused.
>>>>>
>>>>>
>>>>>Any useful help in getting SWT and JDBC to coexist would be greatly
>>>>>appreciated!
>>>>>
>>>>>Thanks in advance.
>>>>>
>>>>>-Lenny Wintfeld
>>>>
>>>>
>>
>
>
|
|
|
Goto Forum:
Current Time: Wed Jun 18 13:54:26 EDT 2025
Powered by FUDForum. Page generated in 0.10484 seconds
|