Posts

Showing posts from January, 2010

Java Code to Connect to MySQL Datatabase Perform Insert and Delete Operation

package mypack; import java.sql.*; import java.io.*;   public class db { Statement smnt;  Connection con;  public db()   {                      try                 {          Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");          con=DriverManager.getConnection("jdbc:odbc:data","root", "1111");                                                               ...

Java Database Connectivity (JDBC) with MySQL

A simple code that finally brought cheer on our face.. Arif and me tried to connect to our mysql database using java. We have done it and were able to connect using odbc driver with ms access. The experiment with mySql was preety difficult without an instructor but finally we made it.   We had to download this file (mysql-connector-odbc-5.1.6-win32) from mysql website for our machine. Once the installation was complete, we went to control panel>administrative tools>odbc driver and picked it up.   Next task it to perform queries on our database   Hope everything goes fine   If you want to connect your mysql with a java program and have any issue, I can certainly help you now as am familiar with it now. J   Happy coding J   Filename db.java import java.sql.*; class db {  public static void main(String args[])  {               ...