Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> ORA-12541 please help...
Hi,
I have just installed Oracle on Red Hat Linux 8.0. I have written a small program that connects to the database gets some data and displays it. The code compile fine but when I try to run it, following exception appears:
java.sql.SQLException ORA-12541.
After doing a bit of research I could figure out that the LSNRCTL may not be working so I tried to restarting it. But still the exception is thrown.
If some one can please guide me.
Thank you in advance
Ashwin.
If interested I am pasting my code below:
import java.sql.*; import java.io.*; import java.net.URL;
class ConnOra {
public static void main(String [] args)
throws SQLException, IOException {
DriverManager.registerDriver(new oracle.jdbc.OracleDriver());
String url ="jdbc:oracle:oci8:@TEST";
try {
String url1 = System.getProperty("JDBC_URL");
if (url1 != null) {
url = url1;
}
} catch (Exception e) {
}
Connection conn =
DriverManager.getConnection(url,"[Usrname]","[passwd]");
conn.setAutoCommit(false);
Statement stmt = conn.createStatement();
ResultSet rs =
stmt.executeQuery("SELECT * FROM Employees");
if (rs.next()) {
System.out.println(rs.getString(1));
}
rs.close();
stmt.close();
conn.close();
}
}
Received on Fri May 30 2003 - 23:03:13 CDT