Skip to main content

Got minus one from a read call

1 reply [Last post]
sameer1sharma
Offline
Joined: 2007-06-19
Points: 0

Exception in thread "main" java.sql.SQLException: Io exception: Got minus one from a read call
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:180)
at oracle.jdbc.dbaccess.DBError.throwSqlException (DBError.java:222)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:335)
at oracle.jdbc.driver.OracleConnection.(OracleConnection.java:361)
at oracle.jdbc.driver.OracleDriver.getConnectionInstance (OracleDriver.java:442)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:321)
at java.sql.DriverManager.getConnection(DriverManager.java:525)
at java.sql.DriverManager.getConnection(DriverManager.java :171)
at emp.Employee.main(Employee.java:40)

My prog:

package emp;

import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager ;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

class Employee
{
public static void main (String args [])
throws SQLException,IOException
{

DriverManager.registerDriver(new oracle.jdbc.OracleDriver());

String url = "jdbc:oracle:thin:@GARDEN:8080:SAMEER";
//String url = "jdbc:oracle:oci8:@";
String userName = "scott";
String password = "tiger";

if (args.length > 0) url = args[0];
if (args.length > 1) userName = args[1];
if (args.length > 2) password = args[2];

Connection conn =
DriverManager.getConnection (url, userName, password);

// Create a Statement
Statement stmt = conn.createStatement ();

// Select the ENAME column from the EMP table
//ResultSet rset = stmt.executeQuery ("select ENAME from EMP");
ResultSet rset = stmt.executeQuery ("select 'Hello Sameer' from dual");
// Iterate through the result and print the employee names

//while (rset.next ())
//System.out.println (rset.getString (1));
}
}

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
neunerball
Offline
Joined: 2005-11-22
Points: 0

Your SQL-Select statement is wrong. It should be as follows:

SELECT * FROM
WHERE =

so, in you case:

SELECT * FROM DUAL WHERE ENAME='Hello Sameer'