NetBeans Forums
| View previous topic :: View next topic |
| Author |
Message |
andForMore
Joined: 25 Jul 2009 Posts: 2
|
Posted: Sat Jul 25, 2009 2:51 am Post subject: Database Connection Issues |
|
|
Hey All.
Its my second day really trying to learn Java, and so far ive been successful with everything, until today, around 4 hours ago, when i decided to try and use a database in this little application i've been building. I keep getting getting this error:
java.lang.ClassNotFoundException: org.apache.derby.jdbc.ClientDriver
Here is the code as it stand right now, although i've tried a hundred different ways, including creating a whole new database and hoping it would, for some reason, work better:
try{
Class.forName("org.apache.derby.jdbc.ClientDriver");
String url = "jdbc:derby://localhost:1527/andy2";
Connection con = DriverManager.getConnection(url, "andy", "andy");
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * FROM SITES");
while (rs.next()) {
...
}
}
catch (Exception e) {
updateStatus("Error connecting to DataBase: "+e.toString());
}
Even when I move different parts of the code into different try/catch blocks, it always stops with the Class.forName part. Ive tried different driver names, but when i click on the database properties this is what it displays as the driver. please help? thanks in advance for any help  |
|
| Back to top |
|
 |
pepelara
Joined: 29 Nov 2008 Posts: 115
|
Posted: Sat Jul 25, 2009 9:16 am Post subject: Database Connection Issues |
|
|
The problem is the Driver. To be sure go to the Admin Console of Glassfish
and look for the
correct Driver of your db.
How can you do it? When started glassfish, right click over the app server
and
open the Admin Console, go to JDBC menu and open Connection Pools.
There you will see the correct Driver
(org.apache.derby.jdbc.ClientDataSource)
You will need information from both JDBC Resources and Connection Pools to
configure
the descriptors of your app.
An entry poin is in the Connection Pools, select your connection and then
the tab Additional Properties.
Over there you will find the description of your database connection.
If need help, post again.
Best Regards,
Jose Alvarez de lara
--------------------------------------------------
From: "andForMore" <address-removed>
Sent: Saturday, July 25, 2009 4:51 AM
To: <address-removed>
Subject: [nbj2ee] Database Connection Issues
| Quote: | Hey All.
Its my second day really trying to learn Java, and so far ive been
successful with everything, until today, around 4 hours ago, when i
decided to try and use a database in this little application i've been
building. I keep getting getting this error:
java.lang.ClassNotFoundException: org.apache.derby.jdbc.ClientDriver
Here is the code as it stand right now, although i've tried a hundred
different ways, including creating a whole new database and hoping it
would, for some reason, work better:
try{
Class.forName("org.apache.derby.jdbc.ClientDriver");
String url = "jdbc:derby://localhost:1527/andy2";
Connection con = DriverManager.getConnection(url, "andy", "andy");
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * FROM SITES");
while (rs.next()) {
...
}
}
catch (Exception e) {
updateStatus("Error connecting to DataBase: "+e.toString());
}
Even when I move different parts of the code into different try/catch
blocks, it always stops with the Class.forName part. Ive tried different
driver names, but when i click on the database properties this is what it
displays as the driver. please help? thanks in advance for any help :-)
|
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You can attach files in this forum You can download files in this forum
|
|