JAVA PROGRAM FOR CONNECT TO DATABASE AND INSERT VALUES INTO STUDENT TABLE USING TYPE1 DRIVER
import java.io.*;
import java.sql.*;
class Dabacon
{
public static void main(String [] args)throws ClassNotFoundException,SQLException
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String url="jdbc:odbc:myds";
String user="mca1230";
String pwd="mca1230";
Connection con=DriverManager.getConnection(url,user,pwd);
Statement st=con.createStatement();
String sql="insert into student values(30,'nagaraju','m','mangalari')";
int n=st.executeUpdate(sql);
if(n!=0)
{
System.out.println("successfully");
}
st.close();
con.close();
}
}
OUTPUT:-