import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class Jdbc10
{
public static void main(String[] args)
{
// Establishing the connection
try(Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1522:xe","system","manager"))
{
// Creating statement to execute query
Statement st=con.createStatement();
// Executing Query
ResultSet rs=st.executeQuery("select * from emp");
System.out.println("ID\tName\tSalary\tJob");
System.out.println("-----------------------------------------");
while(rs.next())
{
System.out.println(rs.getInt(1)+"\t"+rs.getString(2)+"\t"+rs.getFloat(3)+"\t"+rs.getString(4));
}
}
catch(SQLException e)
{
e.printStackTrace();
}
}
}
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class Jdbc10
{
public static void main(String[] args)
{
// Establishing the connection
try(Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1522:xe","system","manager"))
{
// Creating statement to execute query
Statement st=con.createStatement();
// Executing Query
ResultSet rs=st.executeQuery("select * from emp");
System.out.println("ID\tName\tSalary\tJob");
System.out.println("-----------------------------------------");
while(rs.next())
{
System.out.println(rs.getInt(1)+"\t"+rs.getString(2)+"\t"+rs.getFloat(3)+"\t"+rs.getString(4));
}
}
catch(SQLException e)
{
e.printStackTrace();
}
}
}
0 Comment to "Jdbc Program to retrieve all data from 'emp' table of oracle database type-4 driver."
Post a Comment