{ Connection connect = null; Statement statement = null; PreparedStatement preSt = null; ResultSet resultSet = null; String url = "jdbc:mysql://localhost:3306/"; String dbName = "mydb"; String driver = "com.mysql.jdbc.Driver"; String userName = "root"; String password = "promod"; try { Class.forName(driver).newInstance(); Connection conn = DriverManager.getConnection(url+dbName,userName,password); Statement st = conn.createStatement(); // ResultSet res = st.executeQuery("SELECT * FROM mydb"); // while (res.next()) { // int id = res.getInt("id"); // String msg = res.getString("msg"); // System.out.println(id + "\t" + msg); // } int val = st.executeUpdate("INSERT into mydb VALUES("+","+""+")"); if(val==1) System.out.print("Successfully inserted value"); conn.close(); } catch (Exception e) { e.printStackTrace(); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)