open office database in java

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Peter Timbol
    New Member
    • Dec 2006
    • 14

    #1

    open office database in java

    how can i connect an open office database in java?
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Originally posted by Peter Timbol
    how can i connect an open office database in java?
    What do you mean by an office database? Java uses ldbc to connect to databases. You may want to read sun's jdbc tutorial.

    Comment

    • Peter Timbol
      New Member
      • Dec 2006
      • 14

      #3
      i'm using ubuntu.. with open office database..

      import java.sql.*;


      public class DB {

      /**
      * @param args
      */
      public static void main(String[] args) throws Exception {
      // TODO Auto-generated method stub

      Class.forName(" org.hsqldb.jdbc Driver");

      Connection mycon=DriverMan ager.getConnect ion("jdbc:hsqld b:file://home//workspace//Database//db","sa","");
      Statement Que=mycon.creat eStatement();
      ResultSet result=Que.exec uteQuery("SELEC T * FROM Table1");

      }


      im having an exception
      Exception in thread "main" java.lang.Class NotFoundExcepti on: org.hsqldb.jdbc Driver
      at java.net.URLCla ssLoader$1.run( URLClassLoader. java:200)
      at java.security.A ccessController .doPrivileged(N ative Method)
      at java.net.URLCla ssLoader.findCl ass(URLClassLoa der.java:188)
      at java.lang.Class Loader.loadClas s(ClassLoader.j ava:306)
      at sun.misc.Launch er$AppClassLoad er.loadClass(La uncher.java:268 )
      at java.lang.Class Loader.loadClas s(ClassLoader.j ava:251)
      at java.lang.Class Loader.loadClas sInternal(Class Loader.java:319 )
      at java.lang.Class .forName0(Nativ e Method)
      at java.lang.Class .forName(Class. java:164)
      at DB.main(DB.java :12)

      maybe i did not include the hsqldb.jar
      how can i include the file? im using eclipse

      Comment

      • JosAH
        Recognized Expert MVP
        • Mar 2007
        • 11453

        #4
        Originally posted by Peter Timbol
        maybe i did not include the hsqldb.jar
        how can i include the file? im using eclipse
        I'm sure you didn't include it; navigate to:

        Project>Propert ies>Java Build Path>Libraries> Add External Jars ...

        and add the hsqldb.jar file.

        kind regards,

        Jos

        Comment

        • Peter Timbol
          New Member
          • Dec 2006
          • 14

          #5
          its works.. thanks..

          but i'm having Table not found in statement [SELECT ID FROM Assets]

          i think i can figure this out..

          thanks again..

          Comment

          • Peter Timbol
            New Member
            • Dec 2006
            • 14

            #6
            Is openOffice.org database has a different method in displaying filtered contents?

            im having Table not found in java.. and in openoffice itself..

            but in queries tab, it will work.. how can i do that in java?

            Comment

            • r035198x
              MVP
              • Sep 2006
              • 13225

              #7
              Originally posted by Peter Timbol
              Is openOffice.org database has a different method in displaying filtered contents?

              im having Table not found in java.. and in openoffice itself..

              but in queries tab, it will work.. how can i do that in java?
              Perhaps you are passing an incorrect table name (case issues e.t.c).

              Comment

              • Peter Timbol
                New Member
                • Dec 2006
                • 14

                #8
                O just misinterpret the jdbc...

                it will create it's own database file if the file is not present..

                So you need to create tables etc..

                that was great.. thanks guys..

                Comment

                Working...