I need some help using java and mysql. Has anyone heard and used MySql??
I have downloaded and installed the MySql server and created a small database file called t1 (just as a test file). It has one table in it. I have also downloaded a file from the MySql website call a MySql connector for Java. I extracted the files in the MySql directory. But I don't know what to do next. There is a file called MySql-connector-java-3.1.10-bin.jar.
How do I use the MySql server and it databases in a Java program? I have used a Microsoft Access database with a java program. I remember having to go to the windows ODBC Data Source Administrator and add a User DSN for the database file that I wanted to use. I tried doing that but unsuccessfully. MySql wasn't in the list to choose from.
I really need help here. I posted messages at the MySql site but no one has replied.
Richard
09-21-2005, 09:53 AM
pclement
Can't really help you with Java, but did you happen to take a look at the documentation?
Thanks for your reply but do you know where to set tht CLASSPATH so that I can have access to the driver from any directory.
10-02-2005, 09:47 AM
vsorc
copy that .jar file in to ur jre and paste it inside
/jre<version>/lib/ext/
after this u can access the database using jdbc
10-02-2005, 03:19 PM
airrazor
Thanks
Thanks for your help but i am still doing something wrong here. I did what you said to do but it still doesn't work. I get a runtime error SQL Error: java.sql.SQLException: No suitable driver 0 08001
Here is the code I am running:
import java.sql.*;
public class mysqldatabasetest1 {
public static void main(String[] arguments) {
String data = "jdbc:mysql:t1";
try this .....sometimes this will solve the problem
------------------------------------------------
vsorc-:)
10-04-2005, 04:00 PM
airrazor
finally working
I un-installed all of my java components, deleted all of the java directories and then downloaded and installed the latest jdk 5. Then I followed what vsorc suggested to do and it worked. Thanks vsorc for your help. I am using a gui windows application to write my java code (JCreator) and it is working fine now.
Now I just have to be able to make it work from the command line. I am having troubles I think I need to set the path to the java and javac executables because I can't use them from the current directory where the program resides. How do you do this? I thought I knew how but I guess not.