Vignesh Vignesh
asked on
java jdbc
import java.sql.*;
class JdbcInsert1
{
public static void main (String[] args)
{
try
{
Class.forName("oracle.jdbc .driver.Or acleDriver ");
String url = "jdbc:oracle:thin:@elcot-p c:1521:sys tem";
Connection conn = DriverManager.getConnectio n(url,"sys tem","tige r");
Statement st = conn.createStatement();
st.executeUpdate("INSERT INTO customer " +
"VALUES (1001, 'Simpson','mtp')");
st.executeUpdate("INSERT INTO customer " +
"VALUES (1002, 'McBeal','mtp')");
st.executeUpdate("INSERT INTO customer " +
"VALUES (1003, 'Flinstone','mtp')");
st.executeUpdate("INSERT INTO customer " +
"VALUES (1004, 'Cramden', 'mtp')");
conn.close();
}
catch (Exception e)
{
System.err.println("Got an exception! ");
System.err.println(e.getMe ssage());
}
}
}
JdbcInsert.java:15: error: unreported exception ClassNotFoundException; must be
caught or declared to be thrown
Class.forName("oracle.jdbc .driver.Or acleDriver ");
^
1 error
plz anyone tell me solution for this problem
class JdbcInsert1
{
public static void main (String[] args)
{
try
{
Class.forName("oracle.jdbc
String url = "jdbc:oracle:thin:@elcot-p
Connection conn = DriverManager.getConnectio
Statement st = conn.createStatement();
st.executeUpdate("INSERT INTO customer " +
"VALUES (1001, 'Simpson','mtp')");
st.executeUpdate("INSERT INTO customer " +
"VALUES (1002, 'McBeal','mtp')");
st.executeUpdate("INSERT INTO customer " +
"VALUES (1003, 'Flinstone','mtp')");
st.executeUpdate("INSERT INTO customer " +
"VALUES (1004, 'Cramden', 'mtp')");
conn.close();
}
catch (Exception e)
{
System.err.println("Got an exception! ");
System.err.println(e.getMe
}
}
}
JdbcInsert.java:15: error: unreported exception ClassNotFoundException; must be
caught or declared to be thrown
Class.forName("oracle.jdbc
^
1 error
plz anyone tell me solution for this problem
The .jar is eiher not in the right folder, or the classpath hasn't been set properly.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
i am setting classpath like below
D:\oracle\product\10.2.0\d b_1\jdbc\l ib\ojdbc14 .jar;.
this is my error
JdbcInsert.java:15: error: unreported exception ClassNotFoundException; must be
caught or declared to be thrown
Class.forName("oracle.jdbc .driver.Or acleDriver ");
^
1 error
can anyone give the solution plz...
jdbcinsert.java
D:\oracle\product\10.2.0\d
this is my error
JdbcInsert.java:15: error: unreported exception ClassNotFoundException; must be
caught or declared to be thrown
Class.forName("oracle.jdbc
^
1 error
can anyone give the solution plz...
jdbcinsert.java
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
import java.sql.*;
import java.sql.DriverManager;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.ResultSet;
public class jdbcinsert
{
public static void main(String args[])
{
try
{
Class.forName("oracle.jdbc .driver.Or acleDriver ");
Connection connection= DriverManager.getConnectio n(
"jdbc:oracle:thin:@elcot-p c:1521:sys tem", "system", "tiger");
Statement st=connection.createStatem ent();
st.executeUpdate("INSERT INTO customertab"+"VALUES(1001, 'ram')");
connection.close();
}
catch (ClassNotFoundException e)
{
e.printStackTrace();
}
}
}
this is my correct code to run but it has following error
D:\vignesh>javac jdbcinsert.java
jdbcinsert.java:16: error: unreported exception SQLException; must be caught or
declared to be thrown
Connection connection= DriverManager.getConnectio n(
^
jdbcinsert.java:18: error: unreported exception SQLException; must be caught or
declared to be thrown
Statement st=connection.createStatem ent();
^
jdbcinsert.java:19: error: unreported exception SQLException; must be caught or
declared to be thrown
st.executeUpdate("INSERT INTO customertab"+"VALUES(1001, 'ram')");
^
jdbcinsert.java:20: error: unreported exception SQLException; must be caught or
declared to be thrown
connection.close();
^
4 errors
can you give solution to me sir?
import java.sql.DriverManager;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.ResultSet;
public class jdbcinsert
{
public static void main(String args[])
{
try
{
Class.forName("oracle.jdbc
Connection connection= DriverManager.getConnectio
"jdbc:oracle:thin:@elcot-p
Statement st=connection.createStatem
st.executeUpdate("INSERT INTO customertab"+"VALUES(1001,
connection.close();
}
catch (ClassNotFoundException e)
{
e.printStackTrace();
}
}
}
this is my correct code to run but it has following error
D:\vignesh>javac jdbcinsert.java
jdbcinsert.java:16: error: unreported exception SQLException; must be caught or
declared to be thrown
Connection connection= DriverManager.getConnectio
^
jdbcinsert.java:18: error: unreported exception SQLException; must be caught or
declared to be thrown
Statement st=connection.createStatem
^
jdbcinsert.java:19: error: unreported exception SQLException; must be caught or
declared to be thrown
st.executeUpdate("INSERT INTO customertab"+"VALUES(1001,
^
jdbcinsert.java:20: error: unreported exception SQLException; must be caught or
declared to be thrown
connection.close();
^
4 errors
can you give solution to me sir?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Closed.