programming languages

How to insert data in oracle using notepad?

Posted on

JDBC connectivity in java
Database connectivity in java with oracle

import java.sql.*;
import java.util.Scanner;
class Employee
{
public static void main(String args[])
{
Scanner s=new Scanner(System.in);
String url=”jdbc:oracle:thin:@localhost:1521:xe”;
String user=”system”;
String password=”password of oracle”;
int i;
try
{
DriverManager.registerDriver(new oracle.jdbc.OracleDriver());
Connection con=DriverManager.getConnection(url,user,password);
Statement st=con.createStatement();
String sql=”select * from emp”;
ResultSet rs=st.executeQuery(sql);
while(rs.next())
{
System.out.println(rs.getString(1)+”\t”+rs.getInt(2)+”\n”+rs.getString(3));
}
}
catch(Exception ex)
{
System.out.println(ex);
}
}
}

This blog written by Jitendra Kumar a good Java Trainer at Vtech Academy of Computers – Best JAVA Training Institute