Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package javaapplication13;
- /**
- *
- * @author CSE
- */
- import java.sql.*;
- public class NewClass {
- public static void main ( String [] args )
- {
- Connection con=null;
- Statement statement;
- ResultSet result;
- try
- {
- Class.forName("oracle.jdbc.driver.OracleDriver");
- con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE","ABDOULAYE","R154310");
- statement=con.createStatement();
- //int a = 8;
- result = statement.executeQuery("select * from T");
- while(result.next())
- {
- int num= result.getInt(1);
- String name= result.getString(2);
- System.out.println(num + " " + name);
- }
- statement.executeUpdate("update T set name = 'nein' where id=8");
- System.out.println("Successfully updated");
- statement.executeUpdate("delete from T where id=8");
- System.out.println("Successfully deleted");
- statement.executeUpdate("insert into T values(11,'aj')");
- System.out.println("Successfully inserted");
- while(result.next())
- {
- int num= result.getInt(1);
- String name= result.getString(2);
- System.out.println(num + " " + name);
- }
- }
- catch (Exception e)
- {
- System.out.println(e);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement