我在使用spring-boot和sybase的日志中收到了很多SQL警告。
o.h.engine.jdbc.spi.SqlExceptionHelper : [] SQL Warning Code: 0, SQLState: 010SK
o.h.engine.jdbc.spi.SqlExceptionHelper : [] 010SK: Database cannot set connection option SET_READONLY_TRUE.
o.h.engine.jdbc.spi.SqlExceptionHelper : [] 010SK: Database cannot set connection option SET_READONLY_FALSE.
有人能解释一下背后的原因吗?
解决方案1:
java.sql.Connection有一个setReadOnly(boolean(方法,用于通知数据库所请求的结果集的类型,以便执行任何优化。但是Sybase ASE不需要任何优化,因此setReadOnly((会生成一个SQLWarning。
为了抑制该消息,您需要更新MASTER数据库中的spt_mda表。
update spt_mda set querytype = 4, set query = '0'
where mdinfo = 'SET_READONLY_FALSE'
和
update spt_mda set querytype = 4, set query = '0'
where mdinfo = 'SET_READONLY_TRUE'
这两个条目(它们是唯一的条目(默认设置为querytype 3,这意味着";不支持";,这解释了SQLWarning。
将它们改变为查询类型为"0"的4(表示布尔值(;0";基本上会导致JDBC驱动程序在没有警告的情况下返回false。。
解决方案2:
您可以关闭/打开休眠日志记录模块特定部分的日志记录,这些是不同的配置:
# Hibernate logging
# Log everything (a lot of information, but very useful for troubleshooting)
log4j.logger.org.hibernate=FATAL
# Log all SQL DML statements as they are executed
log4j.logger.org.hibernate.SQL=INHERITED
# Log all JDBC parameters
log4j.logger.org.hibernate.type=INHERITED
# Log all SQL DDL statements as they are executed
log4j.logger.org.hibernate.tool.hbm2ddl=INHERITED
# Log the state of all entities (max 20 entities) associated with the session at flush time
log4j.logger.org.hibernate.pretty=INHERITED
# Log all second-level cache activity
log4j.logger.org.hibernate.cache=INHERITED
# Log all OSCache activity - used by Hibernate
log4j.logger.com.opensymphony.oscache=INHERITED
# Log transaction related activity
log4j.logger.org.hibernate.transaction=INHERITED
# Log all JDBC resource acquisition
log4j.logger.org.hibernate.jdbc=INHERITED
# Log all JAAS authorization requests
log4j.logger.org.hibernate.secure=INHERITED
可能值:
OFF
FATAL
ERROR
WARN
INFO
DEBUG
TRACE
ALL