import java.sql.*;
public class Connect
{
public static Connection getcon()
throws SQLException, ClassNotFoundException
{
Class.forName("oracle.jdbc.driver.OracleDriver");
return
DriverManager.getConnection("jdbc:oracle:thin:@hostname:1521", "log
}
public static void main(String argv[])
throws SQLException, ClassNotFoundException
{
Connection con = getcon();
con.close();
}
}
the errors are :
java.lang.StringIndexOutOfBoundsException: String index out of range: -1
at java.lang.String.substring(String.java)
at oracle.sqlnet.SQLnet.Connect(SQLnet.java:117)
at oracle.jdbc.ttc7.TTC7Protocol.connect(TTC7Protocol.java:983)
at oracle.jdbc.ttc7.TTC7Protocol.logon(TTC7Protocol.java:158)
at
oracle.jdbc.driver.OracleConnection.<init>(OracleConnection.java:93)
at
oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:146)
at java.sql.DriverManager.getConnection(DriverManager.java:91)
at java.sql.DriverManager.getConnection(DriverManager.java:134)
at Connect.getcon(Connect.java:9)
at Connect.main(Connect.java:14)
I put the right values in CLASSPATH,
LD_LIBRARY_PATH, and PATH.
I am using JDK 1.1.3 and the last versions of JSQL anf JDBC found on
Oracle server.
Any suggestions?
as i recall from a while back when i used the thin driver, the connection
string should look something like:
"jdbc:oracle:thin:<hostname>:<port #>:<instance>"
then the additional strings passed should be "<username>" and "<password>"
you are using the @hostname syntax, which i didn't think was legal in the
thin driver... (i thought that suggested a TNS name, which, i thought, the
thin driver has no knowledge of)... this implies that the drivers also
wouldn't know which instance to connect to either...
the examples in oracle's thin driver, i thought, were just like the one i
have discussed above..
check into that a bit more closely..
i certainly could be wrong, but something sticks in my mind about the
connection string syntax... :)
cheers!
Peter