JDBC connection from XP client to remote Oracle 10g server using thin driverjdbc version 10.2.0.1.0
Step 1 Create a table and insert some data in Oracle 10g
Step 1 Copy classes12.jar to java/lib
Step 2 Create classpath :) set classpath=C:\Program Files\Java\jdk1.6.0_12\lib\
Step 3 Create below code and change ip as your oracle server ip address
Step 4 Compile the code
Step 5 Execute the code
import java.sql.*;
class sampleDB{
public static void main(String args[]) throws Exception
{ boolean repeat=true;
while(repeat)
{
try {
Class.forName("oracle.jdbc.
Connection con =
DriverManager.getConnection("
System.out.println("Connected Successfully To Oracle");
Statement stmt=con.createStatement();
ResultSet rs=stmt.executeQuery("select * from emp321");
while(rs.next())
{
int no=rs.getInt(1);
String name=rs.getString(2);
float sal=rs.getFloat(3);
System.out.println("EMPLOYEE NO:"+no);
System.out.println("EMPLOYEE NAME:"+name);
System.out.println("EMPLOYEE SAL:"+sal);
System.out.println("----------
} repeat=false; }
catch(Exception e)
{ System.out.println("exception is raised,try again"); }
} }
}
Hope you enjoy :)
Janardhan..
1521 port only working why other ports are not working?
ReplyDeleteThanks
Ram