Java Mysql Database Connectivity without download mysql connector file [use netbeans] - krButani
package javaconnectivity;
import java.sql.*;
public class Javaconnectivity {
/**
* @param args the command line arguments
*/
public static void main(String[] args) throws Exception {
Driver dr = new com.mysql.jdbc.Driver();
DriverManager.registerDriver(dr);
Connection cn = DriverManager.getConnection("jdbc:mysql://localhost:3306/testDemo?zeroDateTimeBehavior=convertToNull","root","mysql");
Statement st = cn.createStatement();
String str = "Create table tbldemo(fname varchar(20))";
st.executeUpdate(str);
str = "INSERT INTO tbldemo VALUES('krButani'),('Raj')";
st.executeUpdate(str);
cn.close();
}
}
Comments
Post a Comment