tag:blogger.com,1999:blog-16506996.post115379296683949441..comments2024-02-08T01:57:07.944-07:00Comments on The Digital Voice: Java: Creating a JDBC Connection to OpenOffice.Org DatabasesJohn Wardhttp://www.blogger.com/profile/10741149622435353727noreply@blogger.comBlogger20125tag:blogger.com,1999:blog-16506996.post-47491651930748249862012-05-05T09:44:36.685-06:002012-05-05T09:44:36.685-06:00can u help me on this i'm getting this error
...can u help me on this i'm getting this error <br /><br />Test.java:4: error: package org.hsqldb does not exist<br />import org.hsqldb.jdbcDriver;<br /> ^<br />Test.java:9: error: cannot find symbol<br /> jdbcDriver j = new jdbcDriver(); //Instantiate the jdbcDriver from HSQL<br /> ^<br /> symbol: class jdbcDriver<br /> location: class Test<br />Test.java:9: error: cannot find symbol<br /> jdbcDriver j = new jdbcDriver(); //Instantiate the jdbcDriver from HSQL<br /> ^<br /> symbol: class jdbcDriver<br /> location: class Test<br /><br />Can't see why <br />yassineyassinenoreply@blogger.comtag:blogger.com,1999:blog-16506996.post-85325101749511445562012-04-14T14:41:02.565-06:002012-04-14T14:41:02.565-06:00Oh hey sorry, it was a mistake in my logic.. Its w...Oh hey sorry, it was a mistake in my logic.. Its working now, thank you very much..like-ever-beforehttps://www.blogger.com/profile/00526553987634144485noreply@blogger.comtag:blogger.com,1999:blog-16506996.post-28565580444052350952012-04-14T14:32:53.488-06:002012-04-14T14:32:53.488-06:00Hey have you tried running any other query like
SE...Hey have you tried running any other query like<br />SELECT \"some_col\" , \"some_other_col\" FROM \"Customers\" WHERE \"some_col\" = 'value'<br /><br />???<br />I have been able to setup the connection thanks to your post but whenever i try to run a query like the one above it is not able to show any result always saying column not found, i have cross checked the query by running it in OpenOffice Query design it works but in my java code it dosen't.. One thing i have noticed is that if i run SELECT * FROM ____ WHERE ____ then it runs but instead of *(all) if i write some column then it dosen't.. Plz help..like-ever-beforehttps://www.blogger.com/profile/00526553987634144485noreply@blogger.comtag:blogger.com,1999:blog-16506996.post-80290019378288126172011-12-06T21:49:34.193-07:002011-12-06T21:49:34.193-07:00Hey this probably won't work if I also want to...Hey this probably won't work if I also want to be able to add and remove data from the database will it? Because just removing something from the zip file will do nothingKylehttps://www.blogger.com/profile/01888620243385242957noreply@blogger.comtag:blogger.com,1999:blog-16506996.post-58655867581453084892011-11-09T10:53:04.171-07:002011-11-09T10:53:04.171-07:00Looky here, what goofy code scripters have left......Looky here, what goofy code scripters have left.......<br />Me thinks to try and see if it reveals any banking passwordy.<br /><br />Me lucky thing... it doAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-16506996.post-12608282225680073712010-08-16T14:03:03.592-06:002010-08-16T14:03:03.592-06:00for some reason the last of the extracted zip file...for some reason the last of the extracted zip file entries(ooTempDatabaseXXXXtmp.data) is not being deleted by the command:-<br /><br />(new File((String)v.get(len))).delete(); <br /><br />This method actually returns a boolean that indicates whether the file was successfully deleted. From this I have been able to deduce that the command to delete has been called but that the deleting operation has failed. Any idea what could be preventing the deletion?oakienoreply@blogger.comtag:blogger.com,1999:blog-16506996.post-67323782283567360142010-07-09T23:25:09.957-06:002010-07-09T23:25:09.957-06:00hi how i insert or delete a registerhi how i insert or delete a registerBalroghttps://www.blogger.com/profile/02076953008715407018noreply@blogger.comtag:blogger.com,1999:blog-16506996.post-29528477990852142012010-02-21T02:37:30.882-07:002010-02-21T02:37:30.882-07:00Looks like a typo. This was posted before I starte...Looks like a typo. This was posted before I started using the code formatted for HTML. That should read:<br />for (len=0; len > v.size();len++).John Wardhttps://www.blogger.com/profile/10741149622435353727noreply@blogger.comtag:blogger.com,1999:blog-16506996.post-1331322775095708552010-02-20T18:02:52.255-07:002010-02-20T18:02:52.255-07:00what is <> mean manwhat is <> mean manUnknownhttps://www.blogger.com/profile/16097625102005504643noreply@blogger.comtag:blogger.com,1999:blog-16506996.post-35068572905281212352009-07-10T19:56:03.445-06:002009-07-10T19:56:03.445-06:00I have a problem. I copy and paste your code in Ne...I have a problem. I copy and paste your code in NetBeans IDE 6.5, and...<br /><br />Illegal start of expresion ...<br /> for (len=0; len<>v.size();len++) <br /><br />Why?Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-16506996.post-87458114939146017362008-10-31T10:56:00.000-06:002008-10-31T10:56:00.000-06:00Tell me how to execute execute insert and update Q...Tell me how to execute execute insert and update Queries ??<BR/>As above example reads data from a temporary file and not the actual database . after inserting/ updating database how to ensure that the original database has been changed??jackshttps://www.blogger.com/profile/16851637425841419738noreply@blogger.comtag:blogger.com,1999:blog-16506996.post-43243458352646932402008-10-27T07:33:00.000-06:002008-10-27T07:33:00.000-06:00Very Very Thanks Dude ......I will try this..........Very Very Thanks Dude ......<BR/>I will try this........<BR/>Lets see dose that work .,jackshttps://www.blogger.com/profile/16851637425841419738noreply@blogger.comtag:blogger.com,1999:blog-16506996.post-26318848486674243612008-07-19T10:27:00.000-06:002008-07-19T10:27:00.000-06:00I am getting the below error .. Please help out......I am getting the below error .. Please help out.... I am doing it in WinXp.<BR/><BR/>C:\Program Files\Java\jdk1.6.0_07\bin>echo %classpath%<BR/>.;C:\Program Files\Java\jdk1.6.0_07\lib;C:\hsqldb\lib;C:\Program Files\QuickTime<BR/>\QTSystem\QTJava.zip<BR/><BR/>C:\Program Files\Java\jdk1.6.0_07\bin>javac Test.java<BR/>Test.java:4: package org.hsqldb does not exist<BR/>import org.hsqldb.jdbcDriver;<BR/> ^<BR/>Test.java:9: cannot find symbol<BR/>symbol : class jdbcDriver<BR/>location: class Test<BR/> jdbcDriver j = new jdbcDriver(); //Instantiate the jdbcDriver from HSQ<BR/>L<BR/> ^<BR/>Test.java:9: cannot find symbol<BR/>symbol : class jdbcDriver<BR/>location: class Test<BR/> jdbcDriver j = new jdbcDriver(); //Instantiate the jdbcDriver from HSQ<BR/>L<BR/> ^<BR/>Note: Test.java uses unchecked or unsafe operations.<BR/>Note: Recompile with -Xlint:unchecked for details.<BR/>3 errorsAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-16506996.post-53713583201249313192008-07-07T08:50:00.000-06:002008-07-07T08:50:00.000-06:00Ed,If your not finding the HSQLDB driver, its beca...Ed,<BR/><BR/>If your not finding the HSQLDB driver, its because the hsqldb.jar file is not in your classpath. Make sure you include the jar files in OO to keep compatible versions, that should solve the problem.<BR/><BR/>JohnJohn Wardhttps://www.blogger.com/profile/10741149622435353727noreply@blogger.comtag:blogger.com,1999:blog-16506996.post-71951184680793341962008-07-06T14:14:00.000-06:002008-07-06T14:14:00.000-06:00request help in 'building' a link or bridge betwee...request help in 'building' a link or bridge between java & OOo. your sample code fails to find the reference to 'import org.hsqldb.jbdcDriver;' note that java works w/ MS Access, & that the OOo Base lets me create,view,edit.....database & tables. Thanks and regards. Ed SongyUnknownhttps://www.blogger.com/profile/06186156361488548847noreply@blogger.comtag:blogger.com,1999:blog-16506996.post-61086288640614111182008-06-27T15:00:00.000-06:002008-06-27T15:00:00.000-06:00Not sure. I am not sure if OO2.4 uses the same for...Not sure. I am not sure if OO2.4 uses the same format for Base files. I think it does. In which case, you can use Calc just fine, take the data, and pump it into Base using the JDBC connection.John Wardhttps://www.blogger.com/profile/10741149622435353727noreply@blogger.comtag:blogger.com,1999:blog-16506996.post-34751855883494394952008-06-23T02:34:00.000-06:002008-06-23T02:34:00.000-06:00Hi Guys and Girls,Very nice! About to try this cod...Hi Guys and Girls,<BR/><BR/>Very nice! About to try this code, does it work with OO 2.4? I'd like to read *.xls files and export them as jdbc connections, just as ms excel odbc driver. Any clue how i can read a file with OO-calc and 'give it' to OO-base? Then I could use the code above. <BR/><BR/>Thanks FransUnknownhttps://www.blogger.com/profile/07217837768284380609noreply@blogger.comtag:blogger.com,1999:blog-16506996.post-32100943642755414472008-05-11T10:52:00.000-06:002008-05-11T10:52:00.000-06:00Thanks for the useful code.www.ipmango.comThanks for the useful code.<BR/><BR/>www.ipmango.comAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-16506996.post-63751886490301295582008-04-01T08:11:00.000-06:002008-04-01T08:11:00.000-06:00thanks for this code. it was exactly wat i needed....thanks for this code. it was exactly wat i needed. <BR/>only one small advice put your file locatios on top for easy rejuse of the code.<BR/><BR/>Lord NobadyAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-16506996.post-1166175506348891332006-12-15T02:38:00.000-07:002006-12-15T02:38:00.000-07:00Hi, thanks for the sample code. I updated the code...Hi, thanks for the sample code. I updated the code to compile under Java 6 without warning and used the Northwind database from Microsoft Access. Attached is my code.<BR/><BR/>Regards,<BR/><BR/>James Loh<BR/>================<BR/>http://dore.mi.com.my<BR/>"IT's as fundamental as do-re-dot-mi"<BR/><BR/>//C:>set CLASSPATH=.;C:\hsqldb\lib\hsqldb.jar<BR/>//C:>javac odb_read.java<BR/><BR/>import org.hsqldb.*;<BR/>import java.sql.*;<BR/>import java.util.zip.*;<BR/>import java.io.*;<BR/>import java.util.*;<BR/><BR/>public class odb_read <BR/>{<BR/> public static void main(String[] args) {<BR/><BR/> try {<BR/> Class.forName("org.hsqldb.jdbcDriver");<BR/> }<BR/> catch(Exception x) {<BR/> System.out.println("Unable to load the driver class!");<BR/> }<BR/><BR/><BR/> Connection con = null; //Database objects<BR/> Statement com = null;<BR/> ResultSet rec = null;<BR/> ZipFile file = null; //For handling zip files<BR/> ZipEntry ent = null;<BR/> Enumeration en = null; //For the entries in the zip file<BR/> BufferedOutputStream out = null; //For the output from the zip class<BR/> InputStream in = null; //for reading buffers from the zip file<BR/> File f = null; //Used to get a temporary file name, not actually used for anything<BR/> int len; //General length counter for loops<BR/> List<String> v = new ArrayList<String>(); //Stores list of unzipped file for deletion at end of program<BR/><BR/> //Unzip zip file, via info from<BR/> //http://www.devx.com/getHelpOn/10MinuteSolution/20447<BR/><BR/> try {<BR/> //Open the zip file that holds the OO.Org Base file<BR/> file = new ZipFile("/Northwind.odb");<BR/><BR/> //Create a generic temp file. I only need to get the filename from<BR/> //the tempfile to prefix the extracted files for OO Base<BR/> f = File.createTempFile("ooTempDatabase", "tmp");<BR/> f.deleteOnExit();<BR/><BR/> //Get file entries from the zipfile and loop through all of them<BR/> en = file.entries();<BR/><BR/> while (en.hasMoreElements()) {<BR/><BR/> //Get the current element<BR/> ent = (ZipEntry)en.nextElement();<BR/><BR/> //If the file is in the database directory, extract it to our<BR/> //temp folder using the temp filename above as a prefix<BR/><BR/> if (ent.getName().startsWith("database/")) {<BR/><BR/> System.out.println("Extracting File: " + ent.getName());<BR/> byte[] buffer = new byte[1024];<BR/> <BR/> //Create an input stream file the file entry<BR/> in = file.getInputStream(ent);<BR/><BR/> //Create a output stream to write out the entry to, using the<BR/> //temp filename created above<BR/> <BR/> out = new BufferedOutputStream(new FileOutputStream("/tmp/" + f.getName() + "." + ent.getName().substring(9)));<BR/><BR/> //Add the newly created temp file to the tempfile vector for deleting<BR/> //later on<BR/> v.add("/tmp/" + f.getName() + "." + ent.getName().substring(9));<BR/><BR/> //Read the input file into the buffer, then write out to<BR/> //the output file<BR/> while((len = in.read(buffer)) >= 0)<BR/> out.write(buffer, 0, len);<BR/><BR/> //close both the input stream and the output stream<BR/> out.close();<BR/> in.close(); <BR/> }<BR/> }<BR/><BR/> //Close the zip file since the temp files have been created<BR/> file.close();<BR/><BR/> //Create our JDBC connection based on the temp filename used above<BR/><BR/> try {<BR/> con = DriverManager.getConnection("jdbc:hsqldb:file:/tmp/" + f.getName(), "SA", "");<BR/> }<BR/> catch (SQLException x) {<BR/> System.out.println("Couldn't get connection!");<BR/> }<BR/><BR/><BR/> //Create a command object and execute, storing the results in the rec object<BR/> com = con.createStatement();<BR/> rec = com.executeQuery("select * from \"customers\"");<BR/><BR/> //GO through the resultset, and output the results<BR/> while (rec.next())<BR/> System.out.println("Company Name: " + rec.getString("CompanyName") + " Contact Name: " + rec.getString("ContactName"));<BR/> <BR/> //Close all the database objects<BR/> rec.close();<BR/> com.close();<BR/> con.close();<BR/><BR/> //Delete the temporary files, which file names are stored in the v vector<BR/> for (len = 0; len < v.size(); len++)<BR/> (new File((String)v.get(len))).delete();<BR/> }<BR/> catch (Exception e) {<BR/> e.printStackTrace();<BR/> }<BR/> }<BR/>}Anonymousnoreply@blogger.com