import java.sql.*;
public class Ex3
{
public static void main(String arg[]) throws SQLException, ClassNotFoundException
{
String driverClassName="com.mysql.jdbc.Driver";
String url="jdbc:mysql://localhost:3306/test";
String userName="root";
String password="admin";
//load driver class,
Class.forName(driverClassName);
//get the connection
Connection con=DriverManager.getConnection(url,userName,password);
//get the statement
Statement st=con.createStatement();
//execute the query
int count=st.executeUpdate("insert into students values(103,'ram','sec')");
System.out.println("no of rows "+count);
//close the connection
con.close();
}//main
}//class
/*
/*
D:\jdbc>set classpath=D:\softwares\MySQL\new\mysql-connector-java-5.1.18-bin.jar;.;
D:\jdbc>javac Ex3.java
D:\jdbc>java Ex3
*/
*/
public class Ex3
{
public static void main(String arg[]) throws SQLException, ClassNotFoundException
{
String driverClassName="com.mysql.jdbc.Driver";
String url="jdbc:mysql://localhost:3306/test";
String userName="root";
String password="admin";
//load driver class,
Class.forName(driverClassName);
//get the connection
Connection con=DriverManager.getConnection(url,userName,password);
//get the statement
Statement st=con.createStatement();
//execute the query
int count=st.executeUpdate("insert into students values(103,'ram','sec')");
System.out.println("no of rows "+count);
//close the connection
con.close();
}//main
}//class
/*
/*
D:\jdbc>set classpath=D:\softwares\MySQL\new\mysql-connector-java-5.1.18-bin.jar;.;
D:\jdbc>javac Ex3.java
D:\jdbc>java Ex3
*/
*/
No comments:
Post a Comment