Two Laptop Bag*
The moose likes JDBC and the fly likes Kindly let me know to run this particular problem relating JDBC Thin Drivers Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Kindly let me know to run this particular problem relating JDBC Thin Drivers" Watch "Kindly let me know to run this particular problem relating JDBC Thin Drivers" New topic
Author

Kindly let me know to run this particular problem relating JDBC Thin Drivers

abhay das
Greenhorn

Joined: Aug 22, 2001
Posts: 9
Hi,
This Example.java I'm giving from the examples given in the Oracle8i demo.
/*
* This sample shows how to list all the names from the EMP table
*
* It uses the JDBC THIN driver. See the same program in the
* oci8 samples directory to see how to use the other drivers.
*/
// You need to import the java.sql package to use JDBC
import java.sql.*;
class Employee
{
public static void main (String args [])
throws SQLException
{
// Load the Oracle JDBC driver
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
// Connect to the database
// You must put a database name after the @ sign in the connection URL.
// You can use either the fully specified SQL*net syntax or a short cut
// syntax as <host>:<port>:<sid>. The example uses the short cut syntax.
Connection conn =
DriverManager.getConnection ("jdbc racle:thin:@dlsun511:1721:dbms733",
"scott", "tiger");
// Create a Statement
Statement stmt = conn.createStatement ();
// Select the ENAME column from the EMP table
ResultSet rset = stmt.executeQuery ("select ENAME from EMP");
// Iterate through the result and print the employee names
while (rset.next ())
System.out.println (rset.getString (1));
}
}
Ofcourse I know to change the database name and the port no....but even if I change it some problems do occur.
Kindly let me know how to run this particular example and any classpaths or paths are required to be set for this.I'm using JDBC Thin Drivers and have win2000 pro and Oracle8i installed in my machine.I have saved all my .java files in a directory called Abjava in the D: drive in my PC and Oracle8i and JDK1.3 are installed in the same drive too.
Kindly let me know as soon as possible.
Thanx
Abhay.
Jamie Robertson
Ranch Hand

Joined: Jul 09, 2001
Posts: 1879

what problems are you encountering. Narrow it down for us a little! Are you getting and SQLException? java.lang.ClassNotFoundException.... Another place to check is http://otn.oracle.com/tech/java/sqlj_jdbc/htdocs/jdbc_faq.htm
see if your question can be answered in the FAQ's at oracle.
Jamie
 
 
subject: Kindly let me know to run this particular problem relating JDBC Thin Drivers
 
Similar Threads
Cofiguring JDBC
JDBC and Oracle Host
Set classpath problem (Oracle9.01)
First Servlet, Jdbc program :(
excepttion in thread "main" java.sql.SQLException: Io exception: The Network Adapter