how we connect database using oracle 9i with java ?
Printable View
how we connect database using oracle 9i with java ?
THIS IS THE JDBC PROGRAME
import java.sql.*;
import javax.sql.*;
import java.io.*;
public class CSDemo
{
public static void main(String ar[])
{
try
{
Class.forName("oracle.jdbc.driver.OracleDriver");
}
catch(ClassNotFoundException e)
{
System.out.println(e);
}
try
{
Connection
c=DriverManager.getConnection("jdbc:orcle:thin:@localhost:1521:gdn","scott","tiger");
CallableStatement cs=c.prepareCall(" { call pr_nk1 } " );
cs.registerOutParameter(1,Types.VARCHAR);
cs.execute();
String stvalue=null;
stvalue=cs.getString(1);
System.out.println(stvalue);
cs.close();
c.close();
}
catch(SQLExceptin e)
{
System.out.println(e);
}
}
}
BYE,
NIRMAL KUMAR