无法获得JDBC连接。嵌套异常是java.sql.SQLException:JZ002:密码属性“”太长。最大长度为30

时间:2018-07-26 15:04:45

标签: spring spring-jdbc

使用JDBCtemplate创建连接时出现以下错误。

org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is java.sql.SQLException: JZ002: Password property '' too long. Maximum length is 30.
Caused by: java.sql.SQLException: JZ002: Password property '' too long. Maximum length is 30.
    at com.sybase.jdbc3.jdbc.ErrorMessage.raiseError(ErrorMessage.java:559)
    at com.sybase.jdbc3.tds.LoginToken.<init>(LoginToken.java:161)
    at com.sybase.jdbc3.tds.Tds.doLogin(Tds.java:542)
    at com.sybase.jdbc3.tds.Tds.login(Tds.java:484)
    at com.sybase.jdbc3.jdbc.SybConnection.tryLogin(SybConnection.java:247)
    at com.sybase.jdbc3.jdbc.SybConnection.regularConnect(SybConnection.java:223)
    at com.sybase.jdbc3.jdbc.SybConnection.<init>(SybConnection.java:198)
    at com.sybase.jdbc3.jdbc.SybConnection.<init>(SybConnection.java:132)
    at com.sybase.jdbc3.jdbc.SybDriver.connect(SybDriver.java:179)
    at java.sql.DriverManager.getConnection(DriverManager.java:664)
    at java.sql.DriverManager.getConnection(DriverManager.java:208)
    at org.springframework.jdbc.datasource.DriverManagerDataSource.getConnectionFromDriverManager(DriverManagerDataSource.java:291)
    at org.springframework.jdbc.datasource.DriverManagerDataSource.getConnectionFromDriverManager(DriverManagerDataSource.java:277)
    at org.springframework.jdbc.datasource.DriverManagerDataSource.getConnectionFromDriverManager(DriverManagerDataSource.java:259)
    at org.springframework.jdbc.datasource.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:240)
    at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:113)
    at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:79)
    at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:328)
    at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:404)
    at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:412)
    at org.springframework.jdbc.core.JdbcTemplate.queryForObject(JdbcTemplate.java:420)
    at org.springframework.jdbc.core.JdbcTemplate.queryForObject(JdbcTemplate.java:425)
    at org.springframework.jdbc.core.JdbcTemplate.queryForInt(JdbcTemplate.java:434)

我的spring.xml文件

<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource" >
        <property name="driverClassName" value="${driver}" />
        <property name="url" value="${url}" />
        <property name="username" value="${userName}" />
        <property name="password" value="${passwd}" />
    </bean>

我不能更改密码,因为这是UAT环境。有人可以在这里建议任何解决方案吗?我正在使用sybase作为数据库

1 个答案:

答案 0 :(得分:0)

这是Sybase的一项限制-密码不能超过30个字符。 如果您尝试使用更长的密码,它会被修剪为前30个字符。
参见:sybase docs for maximum password length

如果密码是从外部创建的,那么我想您可以这样做,并将长度缩短为30 ...