Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.tools -> problem connecting java with personal oracle 8
Dear Friends,
I am facing a pecular problem in connecting with personal Oracle 8.
The following code compiles successfully but on runtime it gives the error connection refused..
got any ideas??
The error which I get is as follows.....
java.sql.SQLException: Connection refused: no further information at oracle.jdbc.dbaccess.DBError.check_error(DBError.java:228) at oracle.jdbc.driver.OracleConnection.<init>(OracleConnection.java:100) at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:147) at
java.sql.DriverManager.getConnection(DriverManager.java:457) at java.sql.DriverManager.getConnection(DriverManager.java:137) at Employee.main(Employee.java, Compiled Code) Exception in thread "main"Process Exit...
Thanks in advance..
vikram
/* * 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 * oci7 or oci8 samples directories 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:oracle:thin:@127.0.0.1:1521:orcl",
"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));
}
}
thanks in anticipation
vikram Received on Sun Jun 18 2000 - 00:00:00 CDT