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 jdbcapp;
- import java.sql.*;
- import java.util.logging.Level;
- import java.util.logging.Logger;
- /**
- *
- * @author abhis
- */
- public class DatabaseProgram {
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args) {
- // TODO code application logic here
- try
- {
- Class.forName("oracle.jdbc.driver.OracleDriver");
- Connection con;
- con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE","system","system");
- System.out.println("connected");
- Statement stmt=con.createStatement();
- stmt.execute("create table student211(Fname varchar(10),Contno number(10))");
- System.out.println("table created");
- stmt.executeUpdate("insert into student211 values('pk',12345)");
- System.out.println("Data inserted");
- stmt.executeUpdate("update student211 set Fname='sk' where contno=12345");
- System.out.println("Data updated");
- ResultSet rs=stmt.executeQuery("select * from student211");
- while(rs.next())
- {
- System.out.println(rs.getString(1));
- System.out.println(rs.getString(2));
- }
- }
- catch (ClassNotFoundException | SQLException ex) {
- Logger.getLogger(DatabaseProgram.class.getName()).log(Level.SEVERE, null, ex);
- }
- }}
Add Comment
Please, Sign In to add comment