sparkx 0 Report post Posted November 28, 2007 (edited) Now I am a compleate newbie to java. Now just from saying that I will get posts that say "read the basics first" ect. I know the basics but the way I learn isn't just by going over basics. What I want to do/know is if it is possible to connect to a MySQL Database using java. Is it possible and if so how? Tutorials and links to tutorials are welcome along with maby a list of required packages and an example code of connecting/selecting data. This is for MySQL not SQL (I don't know if there is a major difference in java or not). I am currently using SDK1.4.2_16. I have various other packages installed already. I know the basics about java (in 3D at least) but I am compleatly clueless on Java connection to mysql. I think it has something to do with JDBC but I might be wrong.Thanks for all the help,Sparkx Edited November 28, 2007 by sparkx (see edit history) Share this post Link to post Share on other sites
kelvinmaki 0 Report post Posted November 29, 2007 Basically, making Java application connecting to mySQL and any other database eg. ORACLE, its the same. The only different is the connection string. For mySQL, I've used: Connection con = null;Class.forName("com.mysql.jdbc.Driver").newInstance();con = DriverManager.getConnection("jdbc:mysql:///test","root", "secret"); After that, use the con variable to execute all the SQL queries. For how to execute the queries, you can do a google search and you should get a lot of information.Anyway before all the connection to mySQL database, you should import all the classes and installed all mySQL services. Hope this help.import java.sql.Connection;import java.sql.DriverManager;import java.sql.SQLException; Cheers Share this post Link to post Share on other sites
sparkx 0 Report post Posted December 3, 2007 Thansk. I have been having trouble with this still. I get some errors like App notinted or something along those lines. Could anyone post the entire code for connecting and displaying entries. Just say I have a mysql database (on Xisto) called testdb (I guess the name doesn't matter I could alway change it). Then display all the entries for Name that are in testdb. I learn best by jumping right into the code so you don't neccissarly need to explain it (although that would help) but what I am looking for is a complete source (unless that is to long). I have worked with mysql lots in php but for some reason when I upload my java files I can't get them to work.Thank you very much,SparkxNote: I am not exactly sure if the error I am getting is related to the script at all it may be something with my compiler. I have gotten the error on other project also that don't connect to databases, however my compiler works on simple projects still. Share this post Link to post Share on other sites