当前位置: 首页 > 知识库问答 >
问题:

Estado HTTP 500...无法打开连接

钱俊楚
2023-03-14

我在hibernate newbie中使用Spring,我遵循了一步一步的教程,在mysql中它可以工作,但是如果我改为firebird,我会遇到下一个错误。

Estado HTTP 500 - 请求处理失败;嵌套的异常是组织.springframework.事务.无法创建事务异常:无法打开Hibernate会话进行交易;嵌套异常是组织.Hibernate.异常.通用JDBC异常: 无法打开连接

服务器是本地的,因为它是会计数据桌面程序。有人能帮我吗?(我不写类(EmpresasDAO, EmpresasDAOIMPL, EmpresasService, EmpresasServiceIMPL),因为它可以工作。非常感谢。

很抱歉我的英语不好,但我正在学习。

完全错误

Estado HTTP 500 - 请求处理失败;嵌套的异常是组织.springframework.事务.无法创建事务异常:无法打开Hibernate会话进行交易;嵌套异常是组织.Hibernate.异常.通用JDBC异常: 无法打开连接

type Informe de Excepción

mensaje Request processing failed; nested exception is org.springframework.transaction.CannotCreateTransactionException: Could not open Hibernate Session for transaction; nested exception is org.hibernate.exception.GenericJDBCException: Could not open connection

descripción El servidor encontró un error interno que hizo que no pudiera rellenar este requerimiento.

excepción 

org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.transaction.CannotCreateTransactionException: Could not open Hibernate Session for transaction; nested exception is org.hibernate.exception.GenericJDBCException: Could not open connection
    org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:948)
    org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:827)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
    org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:812)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)


causa raíz 

org.springframework.transaction.CannotCreateTransactionException: Could not open Hibernate Session for transaction; nested exception is org.hibernate.exception.GenericJDBCException: Could not open connection
    org.springframework.orm.hibernate4.HibernateTransactionManager.doBegin(HibernateTransactionManager.java:514)
    org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:372)
    org.springframework.transaction.interceptor.TransactionAspectSupport.createTransactionIfNecessary(TransactionAspectSupport.java:417)
    org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:255)
    org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:94)
    org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
    org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
    com.sun.proxy.$Proxy17.findAll(Unknown Source)
    com.atorresbr.springapp.EmpresasController.list(EmpresasController.java:33)
    sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    java.lang.reflect.Method.invoke(Method.java:606)
    org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:219)
    org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:132)
    org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104)
    org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:745)
    org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:686)
    org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80)
    org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:925)
    org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856)
    org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:936)
    org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:827)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
    org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:812)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)


causa raíz 

org.hibernate.exception.GenericJDBCException: Could not open connection
    org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:54)
    org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:125)
    org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:110)
    org.hibernate.engine.jdbc.internal.LogicalConnectionImpl.obtainConnection(LogicalConnectionImpl.java:221)
    org.hibernate.engine.jdbc.internal.LogicalConnectionImpl.getConnection(LogicalConnectionImpl.java:157)
    org.hibernate.internal.SessionImpl.connection(SessionImpl.java:550)
    org.springframework.orm.hibernate4.HibernateTransactionManager.doBegin(HibernateTransactionManager.java:428)
    org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:372)
    org.springframework.transaction.interceptor.TransactionAspectSupport.createTransactionIfNecessary(TransactionAspectSupport.java:417)
    org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:255)
    org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:94)
    org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
    org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
    com.sun.proxy.$Proxy17.findAll(Unknown Source)
    com.atorresbr.springapp.EmpresasController.list(EmpresasController.java:33)
    sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    java.lang.reflect.Method.invoke(Method.java:606)
    org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:219)
    org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:132)
    org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104)
    org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:745)
    org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:686)
    org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80)
    org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:925)
    org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856)
    org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:936)
    org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:827)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
    org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:812)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)


causa raíz 

org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (GDS Exception. 335544569. Dynamic SQL Error

SQL error code = -104

Unexpected end of command - line 1, column 8)
    org.apache.commons.dbcp.BasicDataSource.createPoolableConnectionFactory(BasicDataSource.java:1549)
    org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1388)
    org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:1044)
    org.hibernate.service.jdbc.connections.internal.DatasourceConnectionProviderImpl.getConnection(DatasourceConnectionProviderImpl.java:141)
    org.hibernate.internal.AbstractSessionImpl$NonContextualJdbcConnectionAccess.obtainConnection(AbstractSessionImpl.java:292)
    org.hibernate.engine.jdbc.internal.LogicalConnectionImpl.obtainConnection(LogicalConnectionImpl.java:214)
    org.hibernate.engine.jdbc.internal.LogicalConnectionImpl.getConnection(LogicalConnectionImpl.java:157)
    org.hibernate.internal.SessionImpl.connection(SessionImpl.java:550)
    org.springframework.orm.hibernate4.HibernateTransactionManager.doBegin(HibernateTransactionManager.java:428)
    org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:372)
    org.springframework.transaction.interceptor.TransactionAspectSupport.createTransactionIfNecessary(TransactionAspectSupport.java:417)
    org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:255)
    org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:94)
    org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
    org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
    com.sun.proxy.$Proxy17.findAll(Unknown Source)
    com.atorresbr.springapp.EmpresasController.list(EmpresasController.java:33)
    sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    java.lang.reflect.Method.invoke(Method.java:606)
    org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:219)
    org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:132)
    org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104)
    org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:745)
    org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:686)
    org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80)
    org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:925)
    org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856)
    org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:936)
    org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:827)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
    org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:812)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)

应用配置xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:mvc="http://www.springframework.org/schema/mvc" 
  xmlns:beans="http://www.springframework.org/schema/beans"
  xmlns:context="http://www.springframework.org/schema/context" 
  xmlns:tx="http://www.springframework.org/schema/tx"
  xmlns:p="http://www.springframework.org/schema/p"
  xsi:schemaLocation="http://www.springframework.org/schema/mvc 
  http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd
    http://www.springframework.org/schema/beans 
    http://www.springframework.org/schema/beans/spring-beans.xsd
    http://www.springframework.org/schema/tx 
    http://www.springframework.org/schema/tx/spring-tx-3.2.xsd
    http://www.springframework.org/schema/context 
    http://www.springframework.org/schema/context/spring-context-3.2.xsd">

    <!-- Scans the classpath of this application for @Components @Service @Repository to deploy as 
        beans -->
    <context:component-scan base-package="com.atorresbr.springapp" />

    <!-- Configures the @Controller programming model -->
    <mvc:annotation-driven />

      <!-- Map simple view name such as "test" into /WEB-INF/test.jsp -->
  <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    <property name="prefix" value="/WEB-INF/" />
    <property name="suffix" value=".jsp" />
  </bean>

  <bean id="propertyConfigurer"
        class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"
        p:location="/WEB-INF/jdbc.properties" />

  <!-- JDBC Data Source. It is assumed you have MySQL running on localhost port 3306 with
       username root and blank password. Change below if it's not the case -->

       <bean id="myDataSource"
        class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"
        p:driverClassName="${jdbc.driverClassName}"
        p:url="${jdbc.databaseurl}" 
        p:username="${jdbc.username}"
        p:password="${jdbc.password}" 
        p:validationQuery="${jdbc.validationQuery}" />
 <!--       
  <bean id="myDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
    <property name="driverClassName" value="com.mysql.jdbc.Driver"/>
    <property name="url" value="jdbc:mysql://localhost:3306/pizzashop"/>
    <property name="username" value="root"/>
    <property name="password" value=""/>
    <property name="validationQuery" value="SELECT 1"/>
  </bean>   -->

  <!-- Hibernate Session Factory -->
  <bean id="mySessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
    <property name="dataSource" ref="myDataSource"/>
    <property name="packagesToScan">
      <array>
        <value>com.atorresbr.springapp</value>
      </array>
    </property>
    <property name="hibernateProperties">
    <props>
                <prop key="hibernate.dialect">${jdbc.dialect}</prop>
                <prop key="hibernate.show_sql">true</prop> 
            </props>

    </property>
  </bean>

  <!-- Hibernate Transaction Manager -->
  <bean id="transactionManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager">
    <property name="sessionFactory" ref="mySessionFactory"/>
  </bean>

  <!-- Activates annotation based transaction management -->
  <tx:annotation-driven transaction-manager="transactionManager"/>
</beans>

jdbc.propierties

jdbc.driverClassName= org.firebirdsql.jdbc.FBDriver
jdbc.dialect=org.hibernate.dialect.FirebirdDialect
jdbc.databaseurl=jdbc:firebirdsql:PROSYTH-PC/3050:C:/aplifisa/contcs/CONTBD
jdbc.username=SYSDBA
jdbc.password=masterkey
jdbc.validationQuery=SELECT 1

企业.java

package com.atorresbr.springapp;
// imports ..
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;

import java.sql.Blob;
import java.util.Date;

@Entity
@Table(name = "empresas")
public class Empresas {

@Id @GeneratedValue private long CLAVE;
private String NOMBRE;
private String  DNICIF;
private String SIGLA;
private String VIAPUBLICA;
private String NUMERO;
private String PISO;
private String PUERTA;
private String MUNICIPIO;
private String CODPOSTAL;
private String PROVINCIA;
private String TELEFONO;
private String FAX;
private String ADMON;
private long NIVEL;
private String EJERCICIO;
private Date FECHAINI;
private Date FECHAFIN;
private String PAG_ASIEN;
private String COBROS;
private String OCUPADO;
private String CONTRASE;
private String ACT_CONTRASE;
private String BALANCE;
private String COOPERA;
private String WEB;
private String CORREO;
private String IGIC_IVA;
private String OBSERVACIONES;
private String CONTACTO;
private String TELEFONO_CONT;
private String CODPAIS;
private String TIPO_EMP;
private String BALANCE_UE;
private String E_RETEN;
private Date FECHA_BAJA;
private String GES_PROYECTOS;
private String TOMO_R;
private String LIBRO_R;
private String SECCION_R;
private String FOLIO_R;
private String TIPO_R;
private String HOJA_R;
private String OTROS_R;
private String REGMER;
private Blob SUB_TYPE;
private String ILOGO;
private String INUMERO;
private String WEBCONTACTO;
private String MOVILCONTACTO;
private String REGVENTAS;
private String REGCOMPRAS;
private String SUBC_DESP1;
private String SUBC_DESP2;
private String SUBC_DESP3;
private String SUBC_DESP4;
private String SUBC_DESPI1;
private String SUBC_DESPI2;
private String SUBC_DESPI3;
private String SUBC_DESPI4;
private String SUBC_DESPI5;
private String SUBC_DESPI6;
private String SUBC_DESPC1;
private String SUBC_DESP7;
private String GES_DOCU;
private String CRITERIOCAJA;
private String DOC3W_REFURL;
private String DOC3W_AUTOGESTION;
     /* getters & setters */

  public long getCLAVE() {
    return CLAVE;
}
public void setCLAVE(long CLAVE) {
    this.CLAVE = CLAVE;
}
 public String getNOMBRE() {
    return NOMBRE;
}
public void setNOMBRE(String NOMBRE) {
    this.NOMBRE = NOMBRE;
}
.
.
.

等//二传手。

共有1个答案

施英哲
2023-03-14

您的验证查询无效:Firebird始终需要选择中的from-子句。

将其更改为:

Select 1 from rdb$database
 类似资料:
  • 我正在使用spring hibernate开发一个应用程序,如果我使用的是199.892.2.345这样的数据库,我就可以连接到该数据库并执行cud操作,但是如果我将其更改为spring config中的Vinayaka.cloudapp.net,111这样的云数据库,我会得到下面的错误,下面是我正在使用的spring config文件, 错误

  • 有关您编写的代码问题的问题必须描述特定问题-并且在问题本身中包含有效代码以重现它。有关指导,请参阅SSCCE. org。 在我的应用程序中,我有一个模块,用于在数据库中搜索用户并在jsp内的表中显示他们的信息。我只是在应用程序中设置了Spring Security性。我能够从登录页面连接到数据库,尽管出于某种原因,DAO的CRUD操作(在本例中是搜索)都不起作用。 谢谢,如果我能提供更多信息,请告

  • 我生成了一个。我的SpringMVC Maven Hibernate MySQL应用程序的war文件,该应用程序在本地主机和本地MySQL数据库上运行良好。我配置数据库的方式是通过WebAppConfig。查看应用程序的java文件。属性文件并检索适当的信息。 然后我创建了一个OpenShift帐户并部署了它。war文件。我添加了MySQL和PHPMyAdmin盒带,以便维护数据库。当我试图通过我

  • 我的spring bean出现以下错误, EmployeeService.java config.xml

  • 您好,我正在使用oracle数据库,但在Spring Boot时出现了一些错误:错误是: