[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Newsgroup Home]
|
[news.eclipse.platform.rcp] Re: database connection within a RCP?
|
Nico Bruehl wrote:
Hello :),
I am ceating my very first RCP Application which is supposed to have a database connection implemented. When I run and test the app in eclipse, it runs correctly and the database connectivity is working as supposed. After exporting the product to a standalone application the program still runs fine but it can’t find the database driver, though it is not able to establish a connection to my database.
I already tried setting an absolute driver path, which lead to an error because the driver wasn’t loaded by a class loader before. The same should happen with a relative path (e.g. System.getProperty(“user.dir”) + path) ).
What do you mean 'setting an absolute driver path'? Your jar file needs
to be included in the classpath of your plugin. Put the jar in a
standard location like a subdirectory of your plugin. Be sure its
included in the plugin build and exported with the pplugin into the same
relative location.
Neither the trial of declaring a class-path for the driver in the plugin manifest file nor putting and importing the file through the java/lib/ext folder works.
dont put into /ext folder that asking for big problems.
However, it needs to be declared in the manifest and that should work
without issue. The driver MUST be loaded by your plugin, if its loaded
by any other classloader than the one you make the class.forname call
and the DriverManager calls on it will fail.
As said, running in eclipse is not a problem since eclipse knows that it has to load it first (project > properties > build path > libraries > add external jars).
Since I’m not that experienced yet, I am very thankful for every kind of help/hints about how to declare / set the driver that way that it can be found by the program after it has been exported into a standalone application.
I’m using the database “firebird“ and the current “jaybird-full-2.0.0.jar” driver.
How can I set the driver that way that the information to load it when needed is exported with the product?
Just copying/exporting the driver jar file into the products' folder doesn't help :(
Please, has anyone an idea what to do and how to fix my little problem ?
Example code…:
private void openDB()
{
int i = 0;
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
try
{
Properties props = new Properties();
props.setProperty("user", "bern");
props.setProperty("password", "12345");
props.setProperty("sqlDialect", "3");
props.setProperty("charSet", "Cp1252"); // the WIN1252 char set
props.setProperty("roleName", "ROLE_MA");
Class.forName("org.firebirdsql.jdbc.FBDriver");
as as test you could try
Driver d = org.firebirdsql.jdbc.FBDriver();
d.getConnection("jdbc:firebirdsql:bln9y22c/3050:c://firebird/db/prozerf.gdb",
props);
but this is not very dynamic.
conn = DriverManager.getConnection("jdbc:firebirdsql:bln9y22c/3050:c://firebird/db/prozerf.gdb", props);
stmt = conn.createStatement();
stmt.setQueryTimeout(0);
rs = stmt.executeQuery("querytext");
ResultSetMetaData rsmd = rs.getMetaData();
int j, n = rsmd.getColumnCount();
..
.. and then the resultstrings’ values are put into a table..
Thanks in advance,
Nico
--
View in EZ forum: http://www.eclipsezone.com/eclipse/forums/m91955560.html