Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

JDBC Io exception: SO Exception was generated

Status
Not open for further replies.

rorymurray

Programmer
Oct 16, 2001
44
0
0
AU
Hi,

I have been trying to setup a JDBC conneciton to a database so I can run an applet to add, remove and search a database from the web.

The message:"SQLException: Io exception: SO Exception was generated" is output when I choose the particular option that tries to connect to the database, and no data is returned.

My code is below:

import java.sql.*;
import java.sql.ResultSet;
import java.util.*;

public class DBConnect
{
String results = "";

public DBConnect()
{

Connection connection = null;
Statement stmt = null;
ResultSet resultSet = null;

try
{
Class.forName("oracle.jdbc.driver.OracleDriver");
}
catch(java.lang.ClassNotFoundException e)
{
System.err.print("ClassNotFoundException: ");
System.err.println(e.getMessage());
}

try
{
connection = DriverManager.getConnection("jdbc:eek:racle:thin:mad:cutds.cuin.edu.au", "username", "password");

stmt = connection.createStatement();

resultSet = stmt.executeQuery("SELECT salary FROM answer");


results=resultSet.getString("salary");

}
catch(java.sql.SQLException ex)
{
System.err.print("SQLException: ");
System.err.println(ex.getMessage());
}

try
{
if (stmt!=null)
{stmt.close();}
if (connection!=null)
{connection.close();}
}
catch(Exception e)
{
e.printStackTrace();
}

}//end
public String getResults()
{
return results;
}

//-----------------

Anyone know what an SO Exception is?
 
I am not sure... just thowing out... It could be a socket exception!
 
Have you tried to get more error details using the SQLException methods getErrorCode() and getSQLState()? [morning] HavaTheJut
 
I suspect it may have something to do with applets only being able to establish a connection to the host they came from (and naming of the host, as in my case the application server name was different to the database server name).
I haven't managed to solve this yet but two things would need investigating, the one just mentioned, and, the issue of applets and connections, and signing of applets.

If anyone has anything to add about these issues I would be grateful.

Rory

 
Hiya,

I've just had this problem and solved it.
For the oracle thin client, you need to specify the host address, Port and SID in the connect URL, so in your code, this:-

"jdbc:eek:racle:thin:mad:cutds.cuin.edu.au"

should look more like this:-

"jdbc:eek:racle:thin:mad:cutds.cuin.edu.au:1521:SID"

This info probably comes a little too late for you, but someone else may benefit from it. Anyhow, you're code is quite useful to me thanks, as I was wondering how to open recordsets. he he

Cheers.
 
Did you have to sign the applet for it to work or are you writing an application?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top