Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / January 2006

Tip: Looking for answers? Try searching our database.

JDBC Problem

Thread view: 
mike - 15 Jan 2006 06:37 GMT
I am trying to write some code that will allow me to connect to an
OpenOffice database.  I have created the database.  In Eclipse I
included the hsqldb.jar as an external jar.  When I compile, I get the
following error:

DBDriver.java:23: cannot find symbol
symbol  : class getConnection
location: class java.sql.DriverManager
               conn = new DriverManager.getConnection("jdbc:hsqldb:" +
dbPath,"sa","");
                                                         ^
1 error

dbPath is a string variable that gets passed into the method.  I do
have "import java.sql.*; at the beginning.  Am I missing something?

Here is my source.

import java.sql.*;

public class DBDriver {

       private Connection conn;

       public void DBDriver(String dbPath) {
               try {
                       Class.forName("org.hsqldb.jdbcDriver");
               } catch (ClassNotFoundException e) {
                       System.err.println("Class not found");
                       System.err.println(e.getMessage());
               }

               conn = new DriverManager.getConnection("jdbc:hsqldb:" +
dbPath,"sa","");

       }
}

Fairly simple code, right?  Well, why doesn't it work?  Any
suggestions?

BTW, I am running J2SE 1.5.0_50 in linux.

Thanks

Mike
IchBin - 15 Jan 2006 08:58 GMT
> I am trying to write some code that will allow me to connect to an
> OpenOffice database.  I have created the database.  In Eclipse I
[quoted text clipped - 42 lines]
>
> Mike

Try this..

public void DBDriver(String dbPath)
{
    try
    {
        Class.forName("org.hsqldb.jdbcDriver");
        conn = DriverManager.getConnection("jdbc:hsqldb:" + dbPath,
"sa", "");
    }
    catch (ClassNotFoundException e)
    {
        System.err.println("Class not found");
        System.err.println(e.getMessage());
    }
    catch (SQLException e) {
        System.err.println(e.getMessage());
    }
}

Signature

Thanks in Advance...
IchBin, Pocono Lake, Pa, USA
http://weconsultants.servebeer.com/JHackerAppManager
__________________________________________________________________________

'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor,  Regular Guy (1952-)

mike - 16 Jan 2006 06:07 GMT
Well, I tried that, moving the DriverManager.getConnection to right
after the Class.forName, and it still doesn't work.  Same Error message
as before.

Any other ideas?

Thanks

Mike
IchBin - 16 Jan 2006 08:05 GMT
> Well, I tried that, moving the DriverManager.getConnection to right
> after the Class.forName, and it still doesn't work.  Same Error message
[quoted text clipped - 5 lines]
>
> Mike

Slow down and Look at the code I gave you, again. It was not just doing
what you told me what you did.

*My statement*
conn = DriverManager.getConnection("jdbc:hsqldb:" + dbPath, "sa", "");

*Your statement*
conn = new DriverManager.getConnection("jdbc:hsqldb:" +dbPath,"sa","");
Signature


Thanks in Advance...
IchBin, Pocono Lake, Pa, USA
http://weconsultants.servebeer.com/JHackerAppManager
__________________________________________________________________________

'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor,  Regular Guy (1952-)

mike - 17 Jan 2006 03:10 GMT
ahh!!!  I owe you one.  Haha.  Yeah.  That worked.  Thanks man.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.