import java.sql.*;
import java.io.*;
class InsertTest
{
public static void main(String a[])throws Exception
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter the student name:");
String name=br.readLine();
System.out.println("Enter the course");
String course=br.readLine();
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","system","krishna");
Statement st=con.createStatement();
int result=st.executeUpdate("insert into xyz2 values('"+name+"','"+course+"')");
//result=st.getUpdateCount();
if(result>0)
{
System.out.println( "Successfully inserted");
}
else
{
System.out.println("Insertion failed!");
}
}
}
import java.io.*;
class InsertTest
{
public static void main(String a[])throws Exception
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter the student name:");
String name=br.readLine();
System.out.println("Enter the course");
String course=br.readLine();
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","system","krishna");
Statement st=con.createStatement();
int result=st.executeUpdate("insert into xyz2 values('"+name+"','"+course+"')");
//result=st.getUpdateCount();
if(result>0)
{
System.out.println( "Successfully inserted");
}
else
{
System.out.println("Insertion failed!");
}
}
}
0 Comments