We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpIntegration › connecting to mysql database
Page Index Toggle Pages: 1
connecting to mysql database (Read 4426 times)
connecting to mysql database
Dec 7th, 2005, 4:06pm
 
Hi,

I know, there is another very similar post, but this one is more lowlevel.

I am trying to start a connection from my applet (everything local on my computer) to a mysql database (which is correctly installed and did work in other projects).

I've seen there is this mysql lybrary, where i took the example and tried it. But it doesnt work, there is always an alert like :

MySQL.connect(): Could not find the database driver ( com.mysql.jdbc.Driver ).

java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
at java.net.URLClassLoader$1.run(URLClassLoader.java:199)

What does that mean? Do i have to install the driver manually? I thought it was included in the library.

I need the database to store around 300'000 words, to use it like a lexicon. Am I right, that this will be the fastest way to deal with such a huge amount of data? ( the text file is around 3.4 MB)

thanx for help


Re: connecting to mysql database
Reply #1 - Dec 8th, 2005, 12:25am
 
ok, that was a stupid too early post, I found the problem myself, I had to put the mysql-connector-java-3.1.12-bin.jar file into a code folder of the sketch, and everything worked just fine.

but the question remains, where do i have to put a jar file, so that all my applets or other java applications can get acces to it?
Re: connecting to mysql database
Reply #2 - Dec 8th, 2005, 7:14pm
 
you either use "add file" to add it to your sketch (which will create the code folder and copy it there) or to make it "globally" available, you bundle it as a "library" (libraries/howto.txt) so that you can use sketch -> import library -> mysql or something like that in any application where you'd like to use it.

when you export, anything in the code folder will be added to the exported jar file.
Re: connecting to mysql database
Reply #3 - Dec 8th, 2005, 7:15pm
 
and re: your other question, a database is probably overkill for a 3.4 MB text file. you should be able to read that into ram and play with it with no trouble at all.
Re: connecting to mysql database
Reply #4 - Dec 8th, 2005, 11:28pm
 
re: "a database is probably overkill for a 3.4 MB text file". If the use of the lexicon is simply to check whether a word is in the lexicon, a java.util.HashSet is appropriate.
Re: connecting to mysql database
Reply #5 - Dec 15th, 2005, 1:15pm
 
ok, thanx for your answers. the database actually is slightly overkill for my application, its at least twice as fast with an internal array.

I had a mysql query like this:

msql.query( "SELECT * FROM listOfAllWords WHERE left(word,"+mystr.length()+") = '"+mystr+"' LIMIT "+anzAuswahl);

this means that if i use a java container instead of a mysql database, that i have to go through every entry. which is still quite slow.

are there any really fast ways to do my search? My target is to find all the words that contain certain lettercombinations ( like : a,b returns absolute, albatros... etc.) The best would be, if the letters dont need to appear in the same order inside the word. as they are in the list.

thanx for answers

Re: connecting to mysql database
Reply #6 - Dec 15th, 2005, 11:36pm
 
Your sql code would be better off using WHERE word LIKE "mystr%".  I believe that will be optimized better by MySQL.

For pure Java implementation, you would want to use a range query on a Tree of some sort.  You might look into TreeSet.

edit: but to do what you're saying, you would need to look at every word in your list.  Finding words that begin with something can be optimized a lot more than finding words that contain a substring.
You could make a set of buckets when generating the table (have a list 'a' that has all words with 'a' in them, etc.), but that would only work for finding single-letter words.

Marcello
Page Index Toggle Pages: 1