我有一个spring Boot (vers 2.6.12)项目,其中包含quartz和sybase jconnect驱动程序依赖项(不包括所有其他deps):
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-quartz</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>sybase</groupId>
<artifactId>jconnect</artifactId>
<version>16.04.1</version>
</dependency>
我有我的调度程序配置:
@Configuration
@AllArgsConstructor
public class SchedulerConfig {
private final AutowireCapableBeanFactory beanFactory;
private final DataSource dataSource;
private final ApplicationContext context;
private final QuartzProperties quartzProperties;
@Bean
public SchedulerFactoryBean schedulerFactoryBean() {
var jobs = new SchedulerJobFactory(beanFactory);
jobs.setApplicationContext(context);
var properties = new Properties();
properties.putAll(quartzProperties.getProperties());
var factory = new SchedulerFactoryBean();
factory.setOverwriteExistingJobs(true);
factory.setDataSource(dataSource);
factory.setQuartzProperties(properties);
factory.setJobFactory(jobs);
return factory;
}
}
和我的quartz初始化脚本(它是包含的sybase script的修改版本:
/*==============================================================================*/
/* Clear all tables: */
/*==============================================================================*/
IF (OBJECT_ID('QRTZ_FIRED_TRIGGERS')) IS NOT NULL
begin
execute ('delete from QRTZ_FIRED_TRIGGERS')
end
IF OBJECT_ID('QRTZ_PAUSED_TRIGGER_GRPS') IS NOT NULL
begin
execute ('delete from QRTZ_PAUSED_TRIGGER_GRPS')
end
IF OBJECT_ID('QRTZ_SCHEDULER_STATE') IS NOT NULL
begin
execute ('delete from QRTZ_SCHEDULER_STATE')
end
IF OBJECT_ID('QRTZ_LOCKS') IS NOT NULL
begin
execute ('delete from QRTZ_LOCKS')
end
IF OBJECT_ID('QRTZ_SIMPLE_TRIGGERS') IS NOT NULL
begin
execute ('delete from QRTZ_SIMPLE_TRIGGERS')
end
IF OBJECT_ID('QRTZ_SIMPROP_TRIGGERS') IS NOT NULL
begin
execute ('delete from QRTZ_SIMPROP_TRIGGERS')
end
IF OBJECT_ID('QRTZ_CRON_TRIGGERS') IS NOT NULL
begin
execute ('delete from QRTZ_CRON_TRIGGERS')
end
IF OBJECT_ID('QRTZ_BLOB_TRIGGERS') IS NOT NULL
begin
execute ('delete from QRTZ_BLOB_TRIGGERS')
end
IF OBJECT_ID('QRTZ_TRIGGERS') IS NOT NULL
begin
execute ('delete from QRTZ_TRIGGERS')
end
IF OBJECT_ID('QRTZ_JOB_DETAILS') IS NOT NULL
begin
execute ('delete from QRTZ_JOB_DETAILS')
end
IF OBJECT_ID('QRTZ_CALENDARS') IS NOT NULL
begin
execute ('delete from QRTZ_CALENDARS')
end
/*==============================================================================*/
/* Drop constraints: */
/*==============================================================================*/
IF OBJECT_ID('QRTZ_TRIGGERS') IS NOT NULL
begin
execute ('alter table QRTZ_TRIGGERS drop
constraint FK_triggers_job_details')
end
IF OBJECT_ID('QRTZ_CRON_TRIGGERS') IS NOT NULL
begin
execute ('alter table QRTZ_CRON_TRIGGERS drop
constraint FK_cron_triggers_triggers')
end
IF OBJECT_ID('QRTZ_SIMPLE_TRIGGERS') IS NOT NULL
begin
execute ('alter table QRTZ_SIMPLE_TRIGGERS
drop constraint FK_simple_triggers_triggers')
end
IF OBJECT_ID('QRTZ_SIMPROP_TRIGGERS') IS NOT NULL
begin
execute ('alter table QRTZ_SIMPROP_TRIGGERS
drop constraint FK_simprop_triggers_triggers')
end
IF OBJECT_ID('QRTZ_BLOB_TRIGGERS') IS NOT NULL
begin
execute ('alter table QRTZ_BLOB_TRIGGERS
drop constraint FK_blob_triggers_triggers')
end
/*==============================================================================*/
/* Drop tables: */
/*==============================================================================*/
IF OBJECT_ID('QRTZ_FIRED_TRIGGERS') IS NOT NULL
begin
execute ('drop table QRTZ_FIRED_TRIGGERS')
end
IF OBJECT_ID('QRTZ_PAUSED_TRIGGER_GRPS') IS NOT NULL
begin
execute ('drop table QRTZ_PAUSED_TRIGGER_GRPS')
end
IF OBJECT_ID('QRTZ_SCHEDULER_STATE') IS NOT NULL
begin
execute ('drop table QRTZ_SCHEDULER_STATE')
end
IF OBJECT_ID('QRTZ_LOCKS') IS NOT NULL
begin
execute ('drop table QRTZ_LOCKS')
end
IF OBJECT_ID('QRTZ_SIMPLE_TRIGGERS') IS NOT NULL
begin
execute ('drop table QRTZ_SIMPLE_TRIGGERS')
end
IF OBJECT_ID('QRTZ_SIMPROP_TRIGGERS') IS NOT NULL
begin
execute ('drop table QRTZ_SIMPROP_TRIGGERS')
end
IF OBJECT_ID('QRTZ_CRON_TRIGGERS') IS NOT NULL
begin
execute ('drop table QRTZ_CRON_TRIGGERS')
end
IF OBJECT_ID('QRTZ_BLOB_TRIGGERS') IS NOT NULL
begin
execute ('drop table QRTZ_BLOB_TRIGGERS')
end
IF OBJECT_ID('QRTZ_TRIGGERS') IS NOT NULL
begin
execute ('drop table QRTZ_TRIGGERS')
end
IF OBJECT_ID('QRTZ_JOB_DETAILS') IS NOT NULL
begin
execute ('drop table QRTZ_JOB_DETAILS')
end
IF OBJECT_ID('QRTZ_CALENDARS') IS NOT NULL
begin
execute ('drop table QRTZ_CALENDARS')
end
/*==============================================================================*/
/* Create tables: */
/*==============================================================================*/
IF OBJECT_ID('QRTZ_CALENDARS') IS NULL
begin
execute('create table QRTZ_CALENDARS (
SCHED_NAME varchar(120) not null,
CALENDAR_NAME varchar(200) not null,
CALENDAR image not null
)')
end
IF OBJECT_ID('QRTZ_CRON_TRIGGERS') IS NULL
begin
execute('create table QRTZ_CRON_TRIGGERS (
SCHED_NAME varchar(120) not null,
TRIGGER_NAME varchar(200) not null,
TRIGGER_GROUP varchar(200) not null,
CRON_EXPRESSION varchar(120) not null,
TIME_ZONE_ID varchar(80) null,
)')
end
IF OBJECT_ID('QRTZ_PAUSED_TRIGGER_GRPS') IS NULL
begin
execute('create table QRTZ_PAUSED_TRIGGER_GRPS (
SCHED_NAME varchar(120) not null,
TRIGGER_GROUP varchar(200) not null,
)')
end
IF OBJECT_ID('QRTZ_FIRED_TRIGGERS') IS NULL
begin
execute('create table QRTZ_FIRED_TRIGGERS(
SCHED_NAME varchar(120) not null,
ENTRY_ID varchar(95) not null,
TRIGGER_NAME varchar(200) not null,
TRIGGER_GROUP varchar(200) not null,
INSTANCE_NAME varchar(200) not null,
FIRED_TIME numeric(13,0) not null,
SCHED_TIME numeric(13,0) not null,
PRIORITY int not null,
STATE varchar(16) not null,
JOB_NAME varchar(200) null,
JOB_GROUP varchar(200) null,
IS_NONCONCURRENT bit not null,
REQUESTS_RECOVERY bit not null,
)')
end
IF OBJECT_ID('QRTZ_SCHEDULER_STATE') IS NULL
begin
execute('create table QRTZ_SCHEDULER_STATE (
SCHED_NAME varchar(120) not null,
INSTANCE_NAME varchar(200) not null,
LAST_CHECKIN_TIME numeric(13,0) not null,
CHECKIN_INTERVAL numeric(13,0) not null,
)')
end
IF OBJECT_ID('QRTZ_LOCKS') IS NULL
begin
execute('create table QRTZ_LOCKS (
SCHED_NAME varchar(120) not null,
LOCK_NAME varchar(40) not null,
)')
end
IF OBJECT_ID('QRTZ_JOB_DETAILS') IS NULL
begin
execute('create table QRTZ_JOB_DETAILS (
SCHED_NAME varchar(120) not null,
JOB_NAME varchar(200) not null,
JOB_GROUP varchar(200) not null,
DESCRIPTION varchar(250) null,
JOB_CLASS_NAME varchar(250) not null,
IS_DURABLE bit not null,
IS_NONCONCURRENT bit not null,
IS_UPDATE_DATA bit not null,
REQUESTS_RECOVERY bit not null,
JOB_DATA image null
)')
end
IF OBJECT_ID('QRTZ_SIMPLE_TRIGGERS') IS NULL
begin
execute('create table QRTZ_SIMPLE_TRIGGERS (
SCHED_NAME varchar(120) not null,
TRIGGER_NAME varchar(200) not null,
TRIGGER_GROUP varchar(200) not null,
REPEAT_COUNT numeric(13,0) not null,
REPEAT_INTERVAL numeric(13,0) not null,
TIMES_TRIGGERED numeric(13,0) not null
)')
end
IF OBJECT_ID('QRTZ_SIMPROP_TRIGGERS') IS NULL
begin
execute('CREATE TABLE QRTZ_SIMPROP_TRIGGERS (
SCHED_NAME VARCHAR(120) NOT NULL,
TRIGGER_NAME VARCHAR(200) NOT NULL,
TRIGGER_GROUP VARCHAR(200) NOT NULL,
STR_PROP_1 VARCHAR(512) NULL,
STR_PROP_2 VARCHAR(512) NULL,
STR_PROP_3 VARCHAR(512) NULL,
INT_PROP_1 INT NULL,
INT_PROP_2 INT NULL,
LONG_PROP_1 NUMERIC(13,0) NULL,
LONG_PROP_2 NUMERIC(13,0) NULL,
DEC_PROP_1 NUMERIC(13,4) NULL,
DEC_PROP_2 NUMERIC(13,4) NULL,
BOOL_PROP_1 bit NOT NULL,
BOOL_PROP_2 bit NOT NULL
)')
end
IF OBJECT_ID('QRTZ_BLOB_TRIGGERS') IS NULL
begin
execute('create table QRTZ_BLOB_TRIGGERS (
SCHED_NAME varchar(120) not null,
TRIGGER_NAME varchar(200) not null,
TRIGGER_GROUP varchar(200) not null,
BLOB_DATA image null
)')
end
IF OBJECT_ID('QRTZ_TRIGGERS') IS NULL
begin
execute('create table QRTZ_TRIGGERS (
SCHED_NAME varchar(120) not null,
TRIGGER_NAME varchar(200) not null,
TRIGGER_GROUP varchar(200) not null,
JOB_NAME varchar(200) not null,
JOB_GROUP varchar(200) not null,
DESCRIPTION varchar(250) null,
NEXT_FIRE_TIME numeric(13,0) null,
PREV_FIRE_TIME numeric(13,0) null,
PRIORITY int null,
TRIGGER_STATE varchar(16) not null,
TRIGGER_TYPE varchar(8) not null,
START_TIME numeric(13,0) not null,
END_TIME numeric(13,0) null,
CALENDAR_NAME varchar(200) null,
MISFIRE_INSTR smallint null,
JOB_DATA image null
)')
end
/*==============================================================================*/
/* Create primary key constraints: */
/*==============================================================================*/
IF OBJECT_ID('QRTZ_CALENDARS') IS NOT NULL
begin
execute ('alter table QRTZ_CALENDARS
add constraint PK_qrtz_calendars primary key clustered (SCHED_NAME,CALENDAR_NAME)')
end
IF OBJECT_ID('QRTZ_CRON_TRIGGERS') IS NOT NULL
begin
execute ('alter table QRTZ_CRON_TRIGGERS
add constraint PK_qrtz_cron_triggers primary key clustered (SCHED_NAME,TRIGGER_NAME, TRIGGER_GROUP)')
end
IF OBJECT_ID('QRTZ_FIRED_TRIGGERS') IS NOT NULL
begin
execute ('alter table QRTZ_FIRED_TRIGGERS
add constraint PK_qrtz_fired_triggers primary key clustered (SCHED_NAME,ENTRY_ID)')
end
IF OBJECT_ID('QRTZ_PAUSED_TRIGGER_GRPS') IS NOT NULL
begin
execute ('alter table QRTZ_PAUSED_TRIGGER_GRPS
add constraint PK_qrtz_paused_trigger_grps primary key clustered (SCHED_NAME,TRIGGER_GROUP)')
end
IF OBJECT_ID('QRTZ_SCHEDULER_STATE') IS NOT NULL
begin
execute ('alter table QRTZ_SCHEDULER_STATE
add constraint PK_qrtz_scheduler_state primary key clustered (SCHED_NAME,INSTANCE_NAME)')
end
IF OBJECT_ID('QRTZ_LOCKS') IS NOT NULL
begin
execute ('alter table QRTZ_LOCKS
add constraint PK_qrtz_locks primary key clustered (SCHED_NAME,LOCK_NAME)')
end
IF OBJECT_ID('QRTZ_JOB_DETAILS') IS NOT NULL
begin
execute ('alter table QRTZ_JOB_DETAILS
add constraint PK_qrtz_job_details primary key clustered (SCHED_NAME,JOB_NAME, JOB_GROUP)')
end
IF OBJECT_ID('QRTZ_SIMPLE_TRIGGERS') IS NOT NULL
begin
execute ('alter table QRTZ_SIMPLE_TRIGGERS
add constraint PK_qrtz_simple_triggers primary key clustered (SCHED_NAME,TRIGGER_NAME, TRIGGER_GROUP)')
end
IF OBJECT_ID('QRTZ_SIMPROP_TRIGGERS') IS NOT NULL
begin
execute ('alter table QRTZ_SIMPROP_TRIGGERS
add constraint PK_qrtz_simprop_triggers primary key clustered (SCHED_NAME,TRIGGER_NAME, TRIGGER_GROUP)')
end
IF OBJECT_ID('QRTZ_TRIGGERS') IS NOT NULL
begin
execute ('alter table QRTZ_TRIGGERS
add constraint PK_qrtz_triggers primary key clustered (SCHED_NAME,TRIGGER_NAME, TRIGGER_GROUP)')
end
IF OBJECT_ID('QRTZ_BLOB_TRIGGERS') IS NOT NULL
begin
execute ('alter table QRTZ_BLOB_TRIGGERS
add constraint PK_qrtz_blob_triggers primary key clustered (SCHED_NAME,TRIGGER_NAME, TRIGGER_GROUP)')
end
/*==============================================================================*/
/* Create foreign key constraints: */
/*==============================================================================*/
IF OBJECT_ID('QRTZ_CRON_TRIGGERS') IS NOT NULL
begin
execute ('alter table QRTZ_CRON_TRIGGERS
add constraint FK_cron_triggers_triggers foreign key (SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP)
references QRTZ_TRIGGERS (SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP)')
end
IF OBJECT_ID('QRTZ_SIMPLE_TRIGGERS') IS NOT NULL
begin
execute ('alter table QRTZ_SIMPLE_TRIGGERS
add constraint FK_simple_triggers_triggers foreign key (SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP)
references QRTZ_TRIGGERS (SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP)')
end
IF OBJECT_ID('QRTZ_SIMPROP_TRIGGERS') IS NOT NULL
begin
execute ('alter table QRTZ_SIMPROP_TRIGGERS
add constraint FK_simprop_triggers_triggers foreign key (SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP)
references QRTZ_TRIGGERS (SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP)')
end
IF OBJECT_ID('QRTZ_TRIGGERS') IS NOT NULL
begin
execute ('alter table QRTZ_TRIGGERS
add constraint FK_triggers_job_details foreign key (SCHED_NAME,JOB_NAME,JOB_GROUP)
references QRTZ_JOB_DETAILS (SCHED_NAME,JOB_NAME,JOB_GROUP)')
end
IF OBJECT_ID('QRTZ_BLOB_TRIGGERS') IS NOT NULL
begin
execute ('alter table QRTZ_BLOB_TRIGGERS
add constraint FK_blob_triggers_triggers foreign key (SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP)
references QRTZ_TRIGGERS (SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP)')
end
/*==============================================================================*/
/* End of script. */
/*==============================================================================*/
我正在通过DBeaver对一个sybase示例运行此脚本,没有出现任何问题,详细信息如下:
Server: Adaptive Server Enterprise 16.0.04.02
Driver: jConnect (TM) for JDBC (TM) jConnect (TM) for JDBC(TM)/16.0 SP03 PL02 (Build 27403)/P/EBF27518/JDK 1.6.0/jdbcmain/OPT/Mon Aug 28 18:41:14 PDT 2017
我的(相关) Spring 应用设置:
spring.datasource.url=jdbc:sybase:Tds:localhost:6000/Kustom
spring.datasource.driverClassName=com.sybase.jdbc4.jdbc.SybDriver
spring.datasource.username=user
spring.datasource.password=pass
spring.jpa.database-platform=org.hibernate.dialect.SybaseASE15Dialect
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.SybaseASE15Dialect
spring.jpa.properties.hibernate.use_sql_comments=true
spring.jpa.properties.hibernate.format_sql=true
spring.quartz.job-store-type=jdbc
spring.quartz.jdbc.initialize-schema=always
spring.quartz.jdbc.schema=classpath:jdbc/my_script.sql
spring.quartz.properties.org.quartz.jobStore.tablePrefix=QRTZ_
spring.quartz.properties.org.quartz.jobStore.driverDelegateClass=org.quartz.impl.jdbcjobstore.SybaseDelegate
spring.jpa.show-sql=true
spring.jpa.generate-ddl=true
spring.jpa.hibernate.ddl-auto=update
spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
spring.jpa.hibernate.naming.implicit-strategy=org.hibernate.boot.model.naming.ImplicitNamingStrategyLegacyJpaImpl
logging.level.org.hibernate.type=TRACE
我的应用程序不断失败,并显示以下堆栈跟踪:
2023-02-15 10:48:53.630 INFO 1 --- [ main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.SybaseASE15Dialect
2023-02-15 10:48:53.766 DEBUG 1 --- [ main] o.h.type.spi.TypeConfiguration$Scope : Scoping TypeConfiguration [org.hibernate.type.spi.TypeConfiguration@385ef531] to MetadataBuildingContext [org.hibernate.boot.internal.MetadataBuildingContextRootImpl@7fc645e4]
2023-02-15 10:48:54.136 DEBUG 1 --- [ main] o.h.type.spi.TypeConfiguration$Scope : Scoping TypeConfiguration [org.hibernate.type.spi.TypeConfiguration@385ef531] to SessionFactoryImpl [org.hibernate.internal.SessionFactoryImpl@48284d0e]
2023-02-15 10:48:54.303 WARN 1 --- [ main] o.h.engine.jdbc.spi.SqlExceptionHelper : SQL Error: 911, SQLState: ZZZZZ
2023-02-15 10:48:54.303 ERROR 1 --- [ main] o.h.engine.jdbc.spi.SqlExceptionHelper : Attempt to locate entry in sysdatabases for database 'KUSTOM' by name failed - no entry found under that name. Make sure that name is entered properly.
2023-02-15 10:48:54.307 TRACE 1 --- [ main] o.h.type.spi.TypeConfiguration$Scope : Handling #sessionFactoryClosed from [org.hibernate.internal.SessionFactoryImpl@48284d0e] for TypeConfiguration
2023-02-15 10:48:54.308 DEBUG 1 --- [ main] o.h.type.spi.TypeConfiguration$Scope : Un-scoping TypeConfiguration [org.hibernate.type.spi.TypeConfiguration$Scope@11e33bac] from SessionFactory [org.hibernate.internal.SessionFactoryImpl@48284d0e]
2023-02-15 10:48:54.313 ERROR 1 --- [ main] j.LocalContainerEntityManagerFactoryBean : Failed to initialize JPA EntityManagerFactory: [PersistenceUnit: default] Unable to build Hibernate SessionFactory; nested exception is org.hibernate.exception.GenericJDBCException: Error accessing table metadata
2023-02-15 10:48:54.314 WARN 1 --- [ main] onfigReactiveWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory; nested exception is org.hibernate.exception.GenericJDBCException: Error accessing table metadata
2023-02-15 10:48:54.315 INFO 1 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown initiated...
2023-02-15 10:48:54.946 INFO 1 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown completed.
2023-02-15 10:48:54.958 INFO 1 --- [ main] o.e.jetty.server.handler.ContextHandler : Stopped o.e.j.s.ServletContextHandler@3dd69f5a{/,null,STOPPED}
2023-02-15 10:48:54.999 INFO 1 --- [ main] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2023-02-15 10:48:55.098 ERROR 1 --- [ main] o.s.boot.SpringApplication : Application run failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory; nested exception is org.hibernate.exception.GenericJDBCException: Error accessing table metadata
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1804) ~[spring-beans-5.3.23.jar!/:5.3.23]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:620) ~[spring-beans-5.3.23.jar!/:5.3.23]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) ~[spring-beans-5.3.23.jar!/:5.3.23]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.23.jar!/:5.3.23]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.23.jar!/:5.3.23]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.23.jar!/:5.3.23]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.23.jar!/:5.3.23]
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1154) ~[spring-context-5.3.23.jar!/:5.3.23]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:908) ~[spring-context-5.3.23.jar!/:5.3.23]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583) ~[spring-context-5.3.23.jar!/:5.3.23]
at org.springframework.boot.web.reactive.context.ReactiveWebServerApplicationContext.refresh(ReactiveWebServerApplicationContext.java:64) ~[spring-boot-2.6.12.jar!/:2.6.12]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:745) ~[spring-boot-2.6.12.jar!/:2.6.12]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:420) ~[spring-boot-2.6.12.jar!/:2.6.12]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:307) ~[spring-boot-2.6.12.jar!/:2.6.12]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1317) ~[spring-boot-2.6.12.jar!/:2.6.12]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1306) ~[spring-boot-2.6.12.jar!/:2.6.12]
at com.finastra.fusionlimits.enquiries.scheduler.app.Application.main(Application.java:14) ~[classes!/:1.0.0-SNAPSHOT]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[na:na]
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:49) ~[app.jar:1.0.0-SNAPSHOT]
at org.springframework.boot.loader.Launcher.launch(Launcher.java:108) ~[app.jar:1.0.0-SNAPSHOT]
at org.springframework.boot.loader.Launcher.launch(Launcher.java:58) ~[app.jar:1.0.0-SNAPSHOT]
at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:88) ~[app.jar:1.0.0-SNAPSHOT]
Caused by: javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory; nested exception is org.hibernate.exception.GenericJDBCException: Error accessing table metadata
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:421) ~[spring-orm-5.3.23.jar!/:5.3.23]
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:396) ~[spring-orm-5.3.23.jar!/:5.3.23]
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.afterPropertiesSet(LocalContainerEntityManagerFactoryBean.java:341) ~[spring-orm-5.3.23.jar!/:5.3.23]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1863) ~[spring-beans-5.3.23.jar!/:5.3.23]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1800) ~[spring-beans-5.3.23.jar!/:5.3.23]
... 24 common frames omitted
Caused by: org.hibernate.exception.GenericJDBCException: Error accessing table metadata
at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:42) ~[hibernate-core-5.6.11.Final.jar!/:5.6.11.Final]
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:113) ~[hibernate-core-5.6.11.Final.jar!/:5.6.11.Final]
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:99) ~[hibernate-core-5.6.11.Final.jar!/:5.6.11.Final]
at org.hibernate.tool.schema.extract.internal.AbstractInformationExtractorImpl.convertSQLException(AbstractInformationExtractorImpl.java:118) ~[hibernate-core-5.6.11.Final.jar!/:5.6.11.Final]
at org.hibernate.tool.schema.extract.internal.AbstractInformationExtractorImpl.getTables(AbstractInformationExtractorImpl.java:571) ~[hibernate-core-5.6.11.Final.jar!/:5.6.11.Final]
at org.hibernate.tool.schema.extract.internal.DatabaseInformationImpl.getTablesInformation(DatabaseInformationImpl.java:122) ~[hibernate-core-5.6.11.Final.jar!/:5.6.11.Final]
at org.hibernate.tool.schema.internal.GroupedSchemaMigratorImpl.performTablesMigration(GroupedSchemaMigratorImpl.java:68) ~[hibernate-core-5.6.11.Final.jar!/:5.6.11.Final]
at org.hibernate.tool.schema.internal.AbstractSchemaMigrator.performMigration(AbstractSchemaMigrator.java:220) ~[hibernate-core-5.6.11.Final.jar!/:5.6.11.Final]
at org.hibernate.tool.schema.internal.AbstractSchemaMigrator.doMigration(AbstractSchemaMigrator.java:123) ~[hibernate-core-5.6.11.Final.jar!/:5.6.11.Final]
at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.performDatabaseAction(SchemaManagementToolCoordinator.java:196) ~[hibernate-core-5.6.11.Final.jar!/:5.6.11.Final]
at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.process(SchemaManagementToolCoordinator.java:85) ~[hibernate-core-5.6.11.Final.jar!/:5.6.11.Final]
at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:335) ~[hibernate-core-5.6.11.Final.jar!/:5.6.11.Final]
at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:471) ~[hibernate-core-5.6.11.Final.jar!/:5.6.11.Final]
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:1498) ~[hibernate-core-5.6.11.Final.jar!/:5.6.11.Final]
at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:58) ~[spring-orm-5.3.23.jar!/:5.3.23]
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:365) ~[spring-orm-5.3.23.jar!/:5.3.23]
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:409) ~[spring-orm-5.3.23.jar!/:5.3.23]
... 28 common frames omitted
Caused by: com.sybase.jdbc4.jdbc.SybSQLException: Attempt to locate entry in sysdatabases for database 'KUSTOM' by name failed - no entry found under that name. Make sure that name is entered properly.
at com.sybase.jdbc4.tds.Tds.processEed(Tds.java:4237) ~[jconnect-16.04.1.jar!/:na]
at com.sybase.jdbc4.tds.Tds.nextResult(Tds.java:3346) ~[jconnect-16.04.1.jar!/:na]
at com.sybase.jdbc4.jdbc.ResultGetter.nextResult(ResultGetter.java:78) ~[jconnect-16.04.1.jar!/:na]
at com.sybase.jdbc4.jdbc.SybStatement.nextResult(SybStatement.java:303) ~[jconnect-16.04.1.jar!/:na]
at com.sybase.jdbc4.jdbc.SybStatement.nextResult(SybStatement.java:285) ~[jconnect-16.04.1.jar!/:na]
at com.sybase.jdbc4.jdbc.SybStatement.queryLoop(SybStatement.java:2681) ~[jconnect-16.04.1.jar!/:na]
at com.sybase.jdbc4.jdbc.SybCallableStatement.executeQuery(SybCallableStatement.java:150) ~[jconnect-16.04.1.jar!/:na]
at com.sybase.jdbc4.jdbc.SybDatabaseMetaData.returnResults(SybDatabaseMetaData.java:5552) ~[jconnect-16.04.1.jar!/:na]
at com.sybase.jdbc4.jdbc.SybDatabaseMetaData.getTables(SybDatabaseMetaData.java:4022) ~[jconnect-16.04.1.jar!/:na]
at com.zaxxer.hikari.pool.ProxyDatabaseMetaData.getTables(ProxyDatabaseMetaData.java:68) ~[HikariCP-4.0.3.jar!/:na]
at com.zaxxer.hikari.pool.HikariProxyDatabaseMetaData.getTables(HikariProxyDatabaseMetaData.java) ~[HikariCP-4.0.3.jar!/:na]
at org.hibernate.tool.schema.extract.internal.InformationExtractorJdbcDatabaseMetaDataImpl.processTableResultSet(InformationExtractorJdbcDatabaseMetaDataImpl.java:64) ~[hibernate-core-5.6.11.Final.jar!/:5.6.11.Final]
at org.hibernate.tool.schema.extract.internal.AbstractInformationExtractorImpl.getTables(AbstractInformationExtractorImpl.java:559) ~[hibernate-core-5.6.11.Final.jar!/:5.6.11.Final]
... 40 common frames omitted
PS:使用quartz包含的脚本时出现相同问题(之前链接)。
但是,如果我使用sourceforge驱动程序:
spring.datasource.url=jdbc:jtds:sybase://localhost:6000/Kustom
spring.datasource.driverClassName=net.sourceforge.jtds.jdbc.Driver
# Also need these just for the test connection which sourceforge driver is lacking
spring.datasource.validationQuery=select 1
spring.datasource.hikari.connectionTestQuery=select 1
那么一切似乎都如预期的那样工作。
如何使用更现代的jconnect驱动程序使其工作?
谢谢
1条答案
按热度按时间alen0pnh1#
在这里发帖给任何面临类似问题的人都无济于事。在这种情况下,Hibernate方言似乎默认为不带引号的策略,对于jconnect来说,这使得数据库名称使用大写策略。
您有两种选择,要么提供自己的方言来扩展基本方言,然后自己处理带引号/不带引号的策略(您只需覆盖buildIdentifierHelper方法并使用包含的构建器来设置所需的策略),要么使用以下命令启用带引号的策略:
spring.jpa.properties.hibernate.globally_quoted_identifiers= true
我还补充道:
spring.jpa.properties.hibernate.globally_quoted_identifiers_skip_column_definitions = true
以避免其他方言(来自stackoverflow上的其他源)的一些问题。