我在建立从red hat Linux服务器到Sybase服务器的JDBC连接时遇到了困难。我从SQLException得到的错误代码很简单:"JZ00L:登录失败“,然后是"010HA:服务器拒绝了您使用高可用性特性的请求”。我并没有要求使用HA,实际上只是为了确保将该属性设置为false。
我们在这台red hat Linux服务器上安装了Sqoop,我们可以创建Sqoop作业,这些作业可以很好地连接和查询sybase服务器上的数据。我在Sqoop和我的Java代码中使用相同的驱动程序、连接和身份验证信息。
我在互联网上看到过一些关于代码页的参考,有时会导致问题。但我不知道如何在代码中解决这个问题。
下面是java代码:
import java.sql.*;
import com.sybase.jdbc4.jdbc.SybDriver;
import java.util.Properties;
/**
* A JDBC SELECT (JDBC query) example program.
*/
class Query1 {
public static void main (String[] args) {
try {
SybDriver sd = (SybDriver)Class.forName("com.sybase.jdbc4.jdbc.SybDriver").newInstance();
System.out.println("Driver loaded");
Connection conn = DriverManager.getConnection("jdbc:sybase:Tds:srpsyb25:2025","...","...");
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("SELECT 1 AS One");
while ( rs.next() ) {
String col = rs.getString("One");
System.out.println(col);
}
conn.close();
}
catch (SQLException e)
{
for (SQLException current = e; current != null; current = current.getNextException())
{
System.out.println ("=================================================");
System.out.println("SQL exception : " + current.toString());
System.out.println("SQL State : " + current.getSQLState());
System.out.println("Error Code : " + current.getErrorCode());
Throwable t = current.getCause();
while(t != null) {
System.out.println("Cause: " + t);
t = t.getCause();
}
}
System.exit(1);
}
catch (Exception e) {
System.err.println("Unexpected exception! ");
System.err.println(e.getMessage());
}
}
}以下是控制台输出。请注意,我的类路径仅限于该单一驱动程序,因此我相信我正在使用该驱动程序:
$ java -cp /var/lib/sqoop/jconn4.jar:. Query1
Driver loaded
=================================================
SQL exception : java.sql.SQLException: JZ00L: Login failed. Examine the SQLWarnings chained to this exception for the reason(s).
SQL State : JZ00L
Error Code : 0
=================================================
SQL exception : java.sql.SQLWarning: Login failed.
SQL State : 01ZZZ
Error Code : 4002
=================================================
SQL exception : java.sql.SQLWarning: 010HA: The server denied your request to use the high-availability feature. Please reconfigure your database, or do not request a high-availability session.
SQL State : 010HA
Error Code : 0
=================================================
SQL exception : java.sql.SQLWarning: Login failed.
SQL State : 01ZZZ
Error Code : 4002
=================================================
SQL exception : java.sql.SQLWarning: 010HA: The server denied your request to use the high-availability feature. Please reconfigure your database, or do not request a high-availability session.
SQL State : 010HA
Error Code : 0
$发布于 2017-05-23 14:30:51
我也有同样的错误,但对我来说,这只是一个非常糟糕的错误信息。这只是一个错误的用户/密码组合
我通过使用正确的用户凭据解决了这个问题
https://stackoverflow.com/questions/44031965
复制相似问题