Author |
Message |
Fogmeister
I haven't seen my friends in so long
Joined: Thu Apr 23, 2009 7:35 pm Posts: 6580 Location: Getting there
|
I'm trying to connect to a database on my PC.
It is something I have never done before and I'm struggling to get over the first hurdle.
I am trying to load the driver class...
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
But I get a class not found exception. Now, I know the driver is available as it is included with OpenOffice Base. Is there something I need to do with a file or anything? Or import something into the class?
|
Wed Apr 29, 2009 9:45 pm |
|
![](./styles/hestia/theme/images/spacer.gif) |
forquare1
I haven't seen my friends in so long
Joined: Thu Apr 23, 2009 6:36 pm Posts: 5150 Location: /dev/tty0
|
You'll need to include the driver class, and if using something like Eclipse, tell it to use them as external archives (right click on project > Build path > external archives). Then you can use the connection like this: HTH, Ben
|
Wed Apr 29, 2009 10:14 pm |
|
![](./styles/hestia/theme/images/spacer.gif) |
forquare1
I haven't seen my friends in so long
Joined: Thu Apr 23, 2009 6:36 pm Posts: 5150 Location: /dev/tty0
|
BTW, the com.XXX.YYY.ETC. came as a jar called com.jar
|
Wed Apr 29, 2009 10:15 pm |
|
![](./styles/hestia/theme/images/spacer.gif) |
Fogmeister
I haven't seen my friends in so long
Joined: Thu Apr 23, 2009 7:35 pm Posts: 6580 Location: Getting there
|
Thanks, The trouble I am coming across is that I don't know where the driver class is? What is it? Is it an actual file? Do I have to download it from somewhere? I can't import something if I don't have the class on my computer to import it. So the code I have got ... sun.jdbc.odbc.JDBCDriver ... should that be included by default? Where can I get that from? Where do you get the jar files from? In all the forums I have seen there are people saying "put your jar files into the classpath" but I don't have a jar file? Sorry for being thick ![Sad :(](./images/smilies/icon_e_sad.gif) . Thanks again for the help.
|
Wed Apr 29, 2009 10:23 pm |
|
![](./styles/hestia/theme/images/spacer.gif) |
Fogmeister
I haven't seen my friends in so long
Joined: Thu Apr 23, 2009 7:35 pm Posts: 6580 Location: Getting there
|
That's the code. I missed off the com from the beginning in my OP. Anywho, slowly beginning to work out what I need to do ![Very Happy :D](./images/smilies/icon_e_biggrin.gif)
|
Wed Apr 29, 2009 10:38 pm |
|
![](./styles/hestia/theme/images/spacer.gif) |
forquare1
I haven't seen my friends in so long
Joined: Thu Apr 23, 2009 6:36 pm Posts: 5150 Location: /dev/tty0
|
No worries Oli, I had the same thing two weeks ago...
I nabbed my com.jar file (which is the driver file) from someone else's project which connected to the same database...Then copied the "Class.forName("com.sun.jdbc.odbc.JdbcOdbcDriver");" from their code too...
I think you can go to the website of the people that make the database and download the drivers somehow...Though if the drivers from OpenOffice are in your class path, you might be ok...
|
Wed Apr 29, 2009 10:41 pm |
|
![](./styles/hestia/theme/images/spacer.gif) |
Fogmeister
I haven't seen my friends in so long
Joined: Thu Apr 23, 2009 7:35 pm Posts: 6580 Location: Getting there
|
I've given up for now.
Not even sure I've got anything set up to connect to. (Even if I could get past loading the driver).
Oh well.
|
Wed Apr 29, 2009 10:55 pm |
|
![](./styles/hestia/theme/images/spacer.gif) |
forquare1
I haven't seen my friends in so long
Joined: Thu Apr 23, 2009 6:36 pm Posts: 5150 Location: /dev/tty0
|
What database are you trying to connect to? I presume the OO.o Base db?
|
Thu Apr 30, 2009 7:13 am |
|
![](./styles/hestia/theme/images/spacer.gif) |
Fogmeister
I haven't seen my friends in so long
Joined: Thu Apr 23, 2009 7:35 pm Posts: 6580 Location: Getting there
|
Yeah. TBH I've never done anything with databases at all before (from scratch). I develop in Progress at work which is attached to a database but I would have no idea how to set it up from the beginning. In Open Office I created the database (just with one table atm) and went into preferences and enabled the com.sun.star.comp.sdbc.JdbcDriver connection in the "Connections" tab. Is that all I would need to do to be able to get a connection (database side)? All I need now is to be able to use the JdbcDriver that I enabled but I can't seem to find it or anything info on how to get it.
|
Thu Apr 30, 2009 7:43 am |
|
![](./styles/hestia/theme/images/spacer.gif) |
forquare1
I haven't seen my friends in so long
Joined: Thu Apr 23, 2009 6:36 pm Posts: 5150 Location: /dev/tty0
|
I think this may be of use to use. From what I've read, you use MySQL to connect with the OO.o db...
|
Thu Apr 30, 2009 8:59 am |
|
![](./styles/hestia/theme/images/spacer.gif) |
Fogmeister
I haven't seen my friends in so long
Joined: Thu Apr 23, 2009 7:35 pm Posts: 6580 Location: Getting there
|
Ooh, thanks! I'lll give it a go ![Very Happy :D](./images/smilies/icon_e_biggrin.gif) I'll let you know how it goes tonight!
|
Thu Apr 30, 2009 9:22 am |
|
![](./styles/hestia/theme/images/spacer.gif) |
forquare1
I haven't seen my friends in so long
Joined: Thu Apr 23, 2009 6:36 pm Posts: 5150 Location: /dev/tty0
|
Not that my code is very good, but if you PM me an email address I'll send you the my class I wrote to connect to the db I was using, might be able to strip something out of it? It's a bit crappy as it was only for a script, though Perl would have been easier, I couldn't get my head around it, so write a Java app instead ![Very Happy :D](./images/smilies/icon_e_biggrin.gif) I did ponder whether I could have done it in shell, but the lack of arrays was an issue ![Laughing :lol:](./images/smilies/icon_lol.gif)
|
Thu Apr 30, 2009 9:55 am |
|
![](./styles/hestia/theme/images/spacer.gif) |
Fogmeister
I haven't seen my friends in so long
Joined: Thu Apr 23, 2009 7:35 pm Posts: 6580 Location: Getting there
|
Having read that one through I think that is how to connect OpenOffice to an existing database that is held elsewhere.
|
Thu Apr 30, 2009 5:02 pm |
|
![](./styles/hestia/theme/images/spacer.gif) |
Fogmeister
I haven't seen my friends in so long
Joined: Thu Apr 23, 2009 7:35 pm Posts: 6580 Location: Getting there
|
Woo! I'm slowly, slowly getting there ![Very Happy :D](./images/smilies/icon_e_biggrin.gif) I know have the driver loaded but just need to make sure I have set the database up correctly to actually connect to it. Do you know if there are any MySQL databases just kicking around for people to connect to?
|
Thu Apr 30, 2009 5:41 pm |
|
![](./styles/hestia/theme/images/spacer.gif) |
forquare1
I haven't seen my friends in so long
Joined: Thu Apr 23, 2009 6:36 pm Posts: 5150 Location: /dev/tty0
|
I've got no idea...However you might like to ask the same question on the Java/MySQL forums...(Not sure if MySQL has forums, there is a generic Sun forum though)
|
Thu Apr 30, 2009 6:32 pm |
|
|