Forum at OOoForum.orgThe Forum
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

lost, built db fine but now want my java to connect to it.

Post new topic   Reply to topic Forum Index -> Base
View previous topic :: View next topic  
Author Message

Joined: 19 Nov 2005
Posts: 4

PostPosted: Sat Nov 19, 2005 11:22 pm    Post subject: lost, built db fine but now want my java to connect to it. Reply with quote

So I am totally lost, I built the odb just fine, added my tables, the fields the primary keys just fine. Now I have no clue how to connect to it, I got some sample code here:


 * Created on November 18, 2005, 4:17 PM
 * To change this template, choose Tools | Options and locate the template under
 * the Source Creation and Management node. Right-click the template and choose
 * Open. You can then make changes to the template in the Source Editor.

package studiosnap;
//when a client is made, and a session created, you can op to at any point after that import a folder of jpg's
//into the folder, which basically consists of copying the jpg's to the right folder and building up the catalog

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

 * @author Shane Thomas
public class Main {
    private Connection con;
    private ResultSet rs;
    private Statement st;
    /** Creates a new instance of Main */
    public Main() {

    public void createConnection() {
        try {
            System.out.print ("Connecting to database...");
            con = DriverManager.getConnection("jdbc:hsqldb:file:studiosnap2");
            st = con.createStatement();
        } catch (Exception err) {
            System.err.println("\nERROR: failed to load HSQLDB JDBC driver.");
    public void retrieveRecords() {
        try {   
            rs = st.executeQuery("SELECT * FROM Person");
                System.out.println(rs.getString("lastName") + ",\t\t" + rs.getString("firstName"));
        } catch(SQLException err) {
            System.err.println("\nERROR: failed to retrieve records.");
    public static void main(String[] args) {
        Main app = new Main();

Alas, this doesn't work, it can tell when the file is locked though (ifi have it open) other than that i get the error:

ERROR: failed to retrieve records.
java.sql.SQLException: Table not found in statement [SELECT * FROM Person]
at org.hsqldb.jdbc.Util.sqlException(Unknown Source)
at org.hsqldb.jdbc.jdbcStatement.fetchResult(Unknown Source)
at org.hsqldb.jdbc.jdbcStatement.executeQuery(Unknown Source)
at studiosnap.Main.retrieveRecords(
at studiosnap.Main.main(
Java Result: 1
BUILD SUCCESSFUL (total time: 0 seconds)

so im pretty well lost, any sorta of inkling would help?i saw this:

but doing what got this working for the poster (5th post down) was confusing, and trying it that way it wanted me to create a whole new database (for testing purposes i did). but after creating a table with fields, i couldnt edit the primary key to say auto, and then bringing up the table itsel fdidnt allow me to enter test data.

Needless to say i am in the dark...
any suggestions? links? code snippets? help of anykind.
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic Forum Index -> Base All times are GMT - 8 Hours
Page 1 of 1

Jump to:  
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

Powered by phpBB © 2001, 2005 phpBB Group