Start New Discussion within our Software Development Community

I am going through some tutorials in java and I would like to do my first insert into an SQL express database using java .I saw some tutorial recomending jdbc insert. I would like to know which is the best and most reccomended way to carry out an insert into my Express database, because in VB.Net I use ado.net .

I tried this code and I am getting the following error "Got an exception!
No suitable driver found for jdbc:msql://WEIGHBRIDGE2-PC/sqlexpress/NewDB"

                            import java.sql.*;

public class Insertme {

/**
 * @param args
 */
public static void main(String[] args) {
    // TODO Auto-generated method stub


     try { 
           /* String url = "jdbc:msql://200.210.220.1:1114/Demo"; */
            String url = "jdbc:msql://WEIGHBRIDGE2-PC/sqlexpress/NewDB"; 
            Connection conn = DriverManager.getConnection(url,"",""); 
            Statement st = conn.createStatement(); 
           /*   st.executeUpdate("INSERT INTO MyNames " + 
                "VALUES (Talent, 'Simpson')");    */



            st.executeUpdate("INSERT INTO MyNames  VALUES (Talent, 'Simpson')"); 



         /*   st.executeUpdate("INSERT INTO Customers " + 
                "VALUES (1002, 'McBeal', 'Ms.', 'Boston', 2004)"); 
            st.executeUpdate("INSERT INTO Customers " + 
                "VALUES (1003, 'Flinstone', 'Mr.', 'Bedrock', 2003)"); 
            st.executeUpdate("INSERT INTO Customers " + 
                "VALUES (1004, 'Cramden', 'Mr.', 'New York', 2001)");   */

            conn.close(); 
        } catch (Exception e) { 
            System.err.println("Got an exception! "); 
            System.err.println(e.getMessage()); 

}

}

}

This article has been dead for over six months. Start a new discussion instead.