I am working on a Java project where I make connections to an apache derby database. I have followed below -
I have downloaded Apache Derby Zip file and extracted archive to a folder.
I created environment variables DERBY_HOME, DERBY_INSTALL same way as they've asked for.
I started database server using startNetworkServer.bat in the bin directory of database folder.
I was able to connect to the database server using a Database Manager called JetBrains DataGrip. it worked fine and was able to create tables and inserted data.
But when I used the dbURL (which was used in Database Client) in my java program I'm getting ClassNotFound exception.
Here is the class path I have seen when running the database server.
D:/DevelopmentWorkspace/RunTimes/ApacheDerby10_12/db-derby-10.12.1.1-bin/lib/derby.jar;D:/DevelopmentWorkspace/RunTimes/ApacheDerby10_12/db-
derby-10.12.1.1-bin/lib/derbynet.jar;D:/DevelopmentWorkspace/RunTimes/ApacheDerby10_12/db-derby-10.12.1.1-bin/lib/derbyclient.jar;D:/Develop
mentWorkspace/RunTimes/ApacheDerby10_12/db-derby-10.12.1.1-bin/lib/derbytools.jar;D:/DevelopmentWorkspace/RunTimes/ApacheDerby10_12/db-derby
-10.12.1.1-bin/lib/derbyoptionaltools.jar
Below is the exception I'm seeing
java.lang.ClassNotFoundException: org.apache.derby.jdbc.ClientDriver
Error occurred connecting database at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.Class.forName0(Native Method)
I could clearly see that derby.jdbc.ClientDriver is already there in derbyclient.jar file which was already there in classpath mentioned eariler but still I am receiving error but in Database manager its fine.
Please help.
Related
I want to connect Derby Embedded Database to my Swing Application to be exported as executable file.
I've performed following steps.
I've created Embedded Database from Service Tab.
I've created table in our Embedded Database
create table student(id int, name varchar(50), class varchar(10));
insert into student values(1,'Akshay','FYCS'),(2,'Narayan','SYCS');
select * from student;
I've created Swing Project and Added Libraries of Derby Driver
Then I coded for retrieving value from Database
package embeddeddb;
import java.sql.*;
public class EmbeddedDB
{
public static void main(String[] args) throws SQLException, ClassNotFoundException
{
Class.forName("org.apache.derby.jdbc.EmbeddedDriver");
Connection con=DriverManager.getConnection("jdbc:derby:myDB","username","password");
Statement stmt=con.createStatement();
ResultSet rs=stmt.executeQuery("select NAME from STUDENT where ID=1");
rs.next();
System.out.println(rs.getString(1));
}
}
I got Error like this,
run:
Exception in thread "main" java.sql.SQLException: Database 'myDB' not found.
at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.Util.generateCsSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.Util.generateCsSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedConnection.newSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedConnection.handleDBNotFound(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedConnection.<init>(Unknown Source)
at org.apache.derby.jdbc.InternalDriver.getNewEmbedConnection(Unknown Source)
at org.apache.derby.jdbc.InternalDriver.connect(Unknown Source)
at org.apache.derby.jdbc.InternalDriver.connect(Unknown Source)
at org.apache.derby.jdbc.AutoloadedDriver.connect(Unknown Source)
at java.sql.DriverManager.getConnection(DriverManager.java:664)
at java.sql.DriverManager.getConnection(DriverManager.java:247)
at embeddeddb.EmbeddedDB.main(EmbeddedDB.java:11)
Caused by: ERROR XJ004: Database 'myDB' not found.
at org.apache.derby.iapi.error.StandardException.newException(Unknown Source)
at org.apache.derby.impl.jdbc.SQLExceptionFactory.wrapArgsForTransportAcrossDRDA(Unknown Source)
... 14 more
C:\Users\Dell 7559\AppData\Local\NetBeans\Cache\10.0\executor-snippets\run.xml:111: The following error occurred while executing this line:
C:\Users\Dell 7559\AppData\Local\NetBeans\Cache\10.0\executor-snippets\run.xml:94: Java returned: 1
BUILD FAILED (total time: 0 seconds)
I know the problem is with Connection String.
Connection con=DriverManager.getConnection("jdbc:derby:myDB","username","password");
How to solve it? Please Help.
mydb is a relative path, relative to Derby's system directory, which defaults to the current working directory of your application if you use Derby Embedded. If you use the URL in Netbeans, it is relative to NetBeans current working directory, if you use it from your own application, it is relative to that applications current working directory.
In other words, the database used by jdbc:derby:myDB is application specific (or more correct: current working directory specific). In NetBeans your database exists, in your application it doesn't.
You will either need to use an absolute path to your database, or make sure the database is created in an appropriate location (eg the current working directory of your application) or you need to configure Derby to use a specific directory by setting the system property derby.system.home.
See also the Derby documentation Connecting to databases and more specifically Connecting to databases within the system and Defining the system directory
I built a small test Java EE Entreprise Application using NetBeans. Everything works fine in NetBeans (version 7.3) when I run/debug it.
I'm now trying to deploy the test app using WebStart. To do so, I have setup a GlassFish server of the same version that is in NetBeans (GF 3.1.2.2) and I have the JDK Version 7 U 51 installed on the machine. For right now, I'm trying to run the WebStart app on the same machine that GlassFish is on so I'm guessing it's using JRE 7U51 also.
However, when I launch the client application from within GlassFish admin page (app deployed fine), I get a NullPointerException.
Here's the full exception trace:
java.lang.NullPointerException
at java.io.StringReader.<init>(Unknown Source)
at org.glassfish.appclient.client.JWSAppClientContainerMain.insertMaskingLoader(JWSAppClientContainerMain.java:186)
at org.glassfish.appclient.client.JWSAppClientContainerMain.main(JWSAppClientContainerMain.java:132)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.sun.javaws.Launcher.executeApplication(Unknown Source)
at com.sun.javaws.Launcher.executeMainClass(Unknown Source)
at com.sun.javaws.Launcher.doLaunchApp(Unknown Source)
at com.sun.javaws.Launcher.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Here's the JNPL file I get from GlassFish when I want to WebStart the application:
http://pastebin.com/HPddJA3a
Please note that the JNPL file is autogenerated by GlassFish... my EAR doesn't contain one.
This is my first deployment and I've tried many things.... please help! :)
EDIT: More details on how I deploy and access the client app:
I uploaded the EAR file to Glassfish using the admin console (port 4848) and that deployment is successful (no error messages). Then, in the admin console, I see all my EE components (EJB, app jar, etc) and I can launch the client app. This just links to the following URL: http://server-test.com:8080/EEAppTest/EEAppTestEEClient (not a real URL). When I access it, I get the NullPointerException described above.
I wrote a simple multiplayer JAVA app that can connect to MySQL using JDBC driver.
I ended up packing it up in .jar file. When I was testing on my local machine MacOS, it was fine. (I don't exactly remember all the steps to set up JDBC driver, because it was year ago when I wrote this app). The app at this time connects to an external database on another server (I didn't change that because it had no problems). It would be another error if it was a problem with the remote database.
Now, when I need to put it on production on Windows Server 2003, I keep getting the standard error :
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
And I don't get it, because I think I've done the steps right:
0. Installed Java
1. downloaded this: http://dev.mysql.com/downloads/connector/j/
2. added it to the same folder where the app.jar is
3. wrote in cmd: set CLASSPATH =.;C:\Documents and Settings\Administrator\Desktop\tvplan_exchange\mysql-connector-java-5.1.28-bin.jar
4. tested the variable: echo %CLASSPATH% and it showed the same path
5. runned the app: java -jar app.jar
6. got the error:
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at svagers.Db.connect(Db.java:21)
at svagers.Server.main(Server.java:58)
MYSQL ERRORcom.mysql.jdbc.Driver
Well, for those who think that using app like this is a security error - no worries, that is not a problem, I just need it to be running not to consider risks :)
This is the environment:
OS: Windows Server 2003 (Standard Edition, Service Pack 2)
Java: 1.7.0_45 (SE Runtime Environment
I was going to say "run the app with java -cp %CLASSPATH% -jar app.jar" but then remembered you can't have both: you use either -jar or -cp. See this answer.
Hi I've just installed Pentaho Data Integration v. 5.01 and I'm trying to connect to a database. However, I'm unable to test the connection as I get the error (pasted below).
I have JDK 1.7 installed on the system as well, however I can't seem to locate ojdbc14.jar anywhere.
I downloaded that and pasted it in pentaho's \lib folder but I still get the same error.
Any solutions to this problem?
Error connecting to database [test] : org.pentaho.di.core.exception.KettleDatabaseException:
Error occured while trying to connect to the database
Driver class 'oracle.jdbc.driver.OracleDriver' could not be found, make sure the 'Oracle' driver (jar file) is installed.
oracle.jdbc.driver.OracleDriver
org.pentaho.di.core.exception.KettleDatabaseException:
Error occured while trying to connect to the database
Driver class 'oracle.jdbc.driver.OracleDriver' could not be found, make sure the 'Oracle' driver (jar file) is installed.
oracle.jdbc.driver.OracleDriver
at org.pentaho.di.core.database.Database.normalConnect(Database.java:415)
at org.pentaho.di.core.database.Database.connect(Database.java:353)
at org.pentaho.di.core.database.Database.connect(Database.java:306)
at org.pentaho.di.core.database.Database.connect(Database.java:294)
at org.pentaho.di.core.database.DatabaseFactory.getConnectionTestReport(DatabaseFactory.java:84)
at org.pentaho.di.core.database.DatabaseMeta.testConnection(DatabaseMeta.java:2459)
at org.pentaho.ui.database.event.DataHandler.testDatabaseConnection(DataHandler.java:541)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.pentaho.ui.xul.impl.AbstractXulDomContainer.invoke(AbstractXulDomContainer.java:329)
at org.pentaho.ui.xul.impl.AbstractXulComponent.invoke(AbstractXulComponent.java:139)
at org.pentaho.ui.xul.impl.AbstractXulComponent.invoke(AbstractXulComponent.java:123)
at org.pentaho.ui.xul.swt.tags.SwtButton.access$500(SwtButton.java:26)
at org.pentaho.ui.xul.swt.tags.SwtButton$4.widgetSelected(SwtButton.java:121)
at org.eclipse.swt.widgets.TypedListener.handleEvent(Unknown Source)
at org.eclipse.swt.widgets.EventTable.sendEvent(Unknown Source)
at org.eclipse.swt.widgets.Widget.sendEvent(Unknown Source)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Unknown Source)
at org.eclipse.swt.widgets.Display.readAndDispatch(Unknown Source)
at org.eclipse.jface.window.Window.runEventLoop(Window.java:820)
at org.eclipse.jface.window.Window.open(Window.java:796)
at org.pentaho.ui.xul.swt.tags.SwtDialog.show(SwtDialog.java:375)
at org.pentaho.ui.xul.swt.tags.SwtDialog.show(SwtDialog.java:301)
at org.pentaho.di.ui.core.database.dialog.XulDatabaseDialog.open(XulDatabaseDialog.java:115)
at org.pentaho.di.ui.core.database.dialog.DatabaseDialog.open(DatabaseDialog.java:62)
at org.pentaho.di.ui.spoon.delegates.SpoonDBDelegate.newConnection(SpoonDBDelegate.java:493)
at org.pentaho.di.ui.spoon.delegates.SpoonDBDelegate.newConnection(SpoonDBDelegate.java:478)
at org.pentaho.di.ui.spoon.Spoon.doubleClickedInTree(Spoon.java:2885)
at org.pentaho.di.ui.spoon.Spoon.access$2300(Spoon.java:332)
at org.pentaho.di.ui.spoon.Spoon$27.widgetDefaultSelected(Spoon.java:5657)
at org.eclipse.swt.widgets.TypedListener.handleEvent(Unknown Source)
at org.eclipse.swt.widgets.EventTable.sendEvent(Unknown Source)
at org.eclipse.swt.widgets.Widget.sendEvent(Unknown Source)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Unknown Source)
at org.eclipse.swt.widgets.Display.readAndDispatch(Unknown Source)
at org.pentaho.di.ui.spoon.Spoon.readAndDispatch(Spoon.java:1227)
at org.pentaho.di.ui.spoon.Spoon.waitForDispose(Spoon.java:7368)
at org.pentaho.di.ui.spoon.Spoon.start(Spoon.java:8673)
at org.pentaho.di.ui.spoon.Spoon.main(Spoon.java:625)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.pentaho.commons.launcher.Launcher.main(Launcher.java:134)
Caused by: org.pentaho.di.core.exception.KettleDatabaseException:
Driver class 'oracle.jdbc.driver.OracleDriver' could not be found, make sure the 'Oracle' driver (jar file) is installed.
oracle.jdbc.driver.OracleDriver
at org.pentaho.di.core.database.Database.connectUsingClass(Database.java:474)
at org.pentaho.di.core.database.Database.normalConnect(Database.java:399)
... 45 more
Caused by: java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at org.pentaho.di.core.database.Database.connectUsingClass(Database.java:467)
... 46 more
Try placing the odbc jar file (eg: ojdbc5-11.1.0.7.0.jar) inside the "data-integration/lib" directory of your installation. Don't forget to restart Pentaho to make it work.
Here's my setup. I had this problem and managed to fix it as follows.
I have SQLDeveloper running on my machine and it works OK, even under VPN. However, I was running Spoon and noticed that it wouldn't work if I use VPN.
I have tried to put Oracle JDBC drivers shipped with SQLDeveloper into Pentaho. That didn't work.
However, I noticed that one big difference between SQLDeveloper and Spoon is that they use different
Java runtimes and JDBC Oracle drivers! In particular, my version of SQLDeveloper is running on 32-bit JRE version 1.6.0_11, whereas my system-wide JDK is 64-bit version 1.7.0_03.
I have found the JDBC drivers that SQLDeveloper uses and used them as a replacement for the driver that is shipped with Spoon -- no change.
Then I retargeted Spoon to use the Java runtime used by SQLDeveloper.
I set two environment variables: PENTAHO_JAVA and PENTAHO_JAVA_HOME -- and it works OK now!
For reference, here are my envvars:
PENTAHO_JAVA=C:\opt\sqldeveloper\jdk\jre\bin\java.exe
PENTAHO_JAVA_HOME=c:\opt\sqldeveloper\jdk\jre\
If that is relevant, I am on Windows 7 x64.
1. First go to Oracle Site:
http://www.oracle.com/technetwork/database/features/jdbc/index-091264.html
2. Download 1 file: ojdbc6.jar
(2,739,670 bytes) - (SHA1 Checksum: a483a046eee2f404d864a6ff5b09dc0e1be3fe6c)
Classes for use with JDK 1.6. It contains the JDBC driver classes except classes for NLS support in Oracle Object and Collection types.
3. Copy it into Pentaho folder: C:\Program Files\Pentaho\data-integration\lib
4. Close Spoon if it is open and re-open again. (transferred from the comment of #mishkin - thanks him)
That works on my Windows 7 X64 Pro with latest Pentaho 5.3 Stable.
In Pentaho version 6.0 put the driver (ojdbc6.jar) in: "PentahoInstallation"\design-tools\data-integration\lib and restart the Data Integration ide.
See, guys we doesn't need all these stuff. We need to paste oracle jdbc driver (ojdbc6.jar) in the following location.
C:\Program Files\pentaho\design-tools\report-designer\lib\jdbc
C:\Program Files\pentaho\design-tools\data-integration\lib
C:\Program Files\pentaho\design-tools\aggregation-designer\lib
C:\Program Files\pentaho\design-tools\schema-workbench\lib
try to put ojdbc driver in libext/JDBC in your PDI path (location)
Try putting the jar on tomcat library folder, then restart Pentaho.
Should be here .../biserver-ce-6.0.0.0-353/biserver-ce/tomcat/lib
There are already some drivers here.
I could solve this issue by selecting Oralce Native connection > Hostname as Ip address of DB server > instead of SN00XXXX I had used DB00XXX name for the Database name.
I hope this works for such issues with oracle connectivity.
In my case, the error was in Report designer
The fix: only copy ojdbc14.jar to
\prd-ce-5.0.1-stable\report-designer\lib
and restart the tool.
I have an application acting as a client to a JAX-WS server. The connection works fine if I deploy the application directly by placing the war into the tomcat webapps directory (even if doing a hot deploy). However if I undeploy, then redeploy the application using the tomcat manager (from an automated script) I get the exception below thrown anytime it attempts to establish a connection.
Caused by: java.lang.NullPointerException
at com.ctc.wstx.util.SymbolTable.copyArrays(SymbolTable.java:574)
at com.ctc.wstx.util.SymbolTable.findSymbol(SymbolTable.java:403)
at com.ctc.wstx.sr.StreamScanner.parseLocalName(StreamScanner.java:1770)
at com.ctc.wstx.sr.BasicStreamReader.handleStartElem(BasicStreamReader.java:2914)
at com.ctc.wstx.sr.BasicStreamReader.handleRootElem(BasicStreamReader.java:2093)
at com.ctc.wstx.sr.BasicStreamReader.nextFromProlog(BasicStreamReader.java:2073)
at com.ctc.wstx.sr.BasicStreamReader.next(BasicStreamReader.java:1069)
at com.sun.xml.internal.ws.util.xml.XMLStreamReaderFilter.next(Unknown Source)
at com.sun.xml.internal.ws.streaming.XMLStreamReaderUtil.next(Unknown Source)
at com.sun.xml.internal.ws.streaming.XMLStreamReaderUtil.nextContent(Unknown Source)
at com.sun.xml.internal.ws.streaming.XMLStreamReaderUtil.nextElementContent(Unknown Source)
at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.hasWSDLDefinitions(Unknown Source)
at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.parse(Unknown Source)
at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.parse(Unknown Source)
at com.sun.xml.internal.ws.client.WSServiceDelegate.parseWSDL(Unknown Source)
at com.sun.xml.internal.ws.client.WSServiceDelegate.<init>(Unknown Source)
at com.sun.xml.internal.ws.client.WSServiceDelegate.<init>(Unknown Source)
at com.sun.xml.internal.ws.spi.ProviderImpl.createServiceDelegate(Unknown Source)
[... continues into application specific code calling the service ...]
This post showed up here in a search with someone having a similar problem, but had no resolution other than to use spring-ws which isn't really an option for me at the moment.
Has anyone run into this before and been able to resolve the issue? I'm a bit puzzled by what is going on here to make deployment via the tomcat manager different than deploying by placing the files in webapps.
I also encountered this issue. The problem was that I had a dependency on cxf-rt-frontend-jaxws-2.5.2.jar in my classpath, which contains an implementation of org.apache.cxf.jaxws.spi.ProviderImpl that conflicts with the same class in rt.jar that comes with the JDK.
Later versions of cxf-rt-frontend-jaxws no longer contain this class. After upgrading to cxf-rt-frontend-jaxws-2.6.15.jar, the problem was resolved.
I expect that the problem occurs intermittently because the classloader would randomly choose which implementation of ProviderImpl to use each time the WAR is deployed.
In my case, the problem was on SymbolTable class, which was both on com.sun.org.apache.xerces.internal.util.SymbolTable (from rt.jar) and com.ctc.wstx.util.SymbolTable (from wstx-asl-3.2.7.jar). After removing wstx-asl lib from my classpath we made redeployment via tomcat manager with no errors.