How to access a java Derby database? I could really do with a few helpful pointers?

You seem to be using the network server but your db URL is wrong.

Up vote 1 down vote favorite share g+ share fb share tw.

I am new to using Derby and databses in eclipse, and I have become a tad lost and in need to a bit of help. I have established a database connection, created a new database, and a new schema, within which I have some tables containing some test data. I don't have any problem with the sql queries to select the relevant data.

The problem I have is getting to a point where I can use queries. I am trying to create a class which connects to the database, and for testing purposes, uses a simple query to select some data. This is what I have so far: public void getExerciseInfo() { try { Class.

ForName("org.apache.derby.jdbc. ClientDriver").newInstance(); connect = DriverManager. GetConnection("jdbc:derby://localhost/c:/TestDatabase"); PreparedStatement statement = connect.

PrepareStatement("SELECT * from TESTSCHEMA. TESTTABLE"); resultSet = statement.executeQuery(); while (resultSet.next()) { String name= resultSet. GetString("NAME"); String type = resultSet.

GetString("TYPE"); System.out. Println(name); System.out. Println(type); } } catch (Exception e) { } finally { close(); } } All I am trying to do is output the data in the table to the console, but I cant even do this simple task :( Im guessing my connection url is invalid, is it supposed to be the file path to the database folder in my eclipse workspace?

Anyhow, I am very lost, and any help would be greatly appreciated. Java database database-design database-schema derby link|improve this question asked Aug 7 '11 at 10:38Ben Calder211.

4 catch (Exception e) {} will swallow exceptions. Don't do that. Instead, log it or use e.printStacktrace().

And then update the question with the exception, if you don't know what it is. – Vineet Reynolds Aug 7 '11 at 10:43.

No, I hadn't found that tutorial, but it looks like I should be able to fix it with it, thanks. :) – Ben Calder Aug 9 '11 at 9:19.

If you are not running the Derby server, you can establish an embedded database connection or use an EmbeddedDataSource, shown here.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions