Google 网上论坛不再支持新的 Usenet 帖子或订阅项。历史内容仍可供查看。

Help JSQL, JDBC again

已查看 1 次
跳至第一个未读帖子

Bruno MARQUIE

未读,
1998年3月30日 03:00:001998/3/30
收件人

Hello , last week I send a mail about a problem with JDBC connection.
I receive answers, and made corrections. Now I've other problems. Help
me please.
So I just tried to do a connection with this simple program and that
doesnt work:

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?

Peter Dohm

未读,
1998年3月30日 03:00:001998/3/30
收件人

hm...

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

0 个新帖子