这是hibernate.cfg.xml:
<!-- hibernate dialect -->
<property name="hibernate.dialect">org.hibernate.dialect.OracleDialect</property>
<property name="hibernate.connection.driver_class">oracle.jdbc.driver.Oracle Driver</property>
<property name="hibernate.connection.url">jdbc:oracle:thin:@localhost:1521:xe</property>
<property name="hibernate.connection.username">system</property>
<property name="hibernate.connection.password">oracle</property>
<property name="transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</property>
<!-- Automatic schema creation (begin) === -->
<property name="hibernate.hbm2ddl.auto">none</property>
<!-- Simple memory-only cache -->
<property name="hibernate.cache.provider_class">org.hibernate.cache.HashtableCacheProvider</property>
<!-- Enable Hibernate's automatic session context management -->
<property name="current_session_context_class">thread</property>
<!-- <property name="show_sql">true</property> -->
<mapping class="com.infy.EPP.entites.LoginEntity" />
</session-factory>
这是Hibernate实用程序文件:
public class HibernateUtility
{
private static final String CONFIGURATION_LOCATION = "com/infy/EPP/resources/hibernate.cfg.xml";
private static SessionFactory sessionFactory = null;
private static ServiceRegistry serviceRegistry;
public synchronized static SessionFactory createSessionFactory() {
if (sessionFactory == null)
{
try {
// Step1 : Loading the configuration details from
// hibernate.cfg.xml
Configuration configuration = new Configuration()
.configure(CONFIGURATION_LOCATION);
System.out.println("configuration in Utility=="+configuration); //---//syso1
// Step2 : Creating ServiceRegistry using the
// StandardServiceRegistryBuilder and Configuration defined in
// Step 1
serviceRegistry = new StandardServiceRegistryBuilder()
.applySettings(configuration.getProperties()).build();
System.out.println("serviceRegistry=="+serviceRegistry); ---//syso 2
// Step3 : Creating the SessionFactory using the Configuration
// and serviceRegistry.
sessionFactory = configuration
.buildSessionFactory(serviceRegistry);
System.out.println("sessionFactory==="+sessionFactory); ---//syso 3
}
catch (Exception e)
{
e.printStackTrace();
EppLogger.logError("HibernateUtility",
"createSessionFactory", e.getMessage());
}
}
return sessionFactory;
}
}
public Login authorize(Login to) throws Exception
{
LoginEntity le = null;
SessionFactory sessionFactory = null;
Session session = null;
Login login =null;
try {
sessionFactory = HibernateUtility.createSessionFactory();
session=sessionFactory.openSession();
session.beginTransaction();
le = (LoginEntity)session.get(LoginEntity.class, to.getUserId());
if (le != null)
{
login = new Login();
login.setPassword(le.getPassword());
login.setRole(le.getRole());
login.setStatus(le.getStatus());
login.setUserId(le.getUserId());
}
session.getTransaction().commit();
}
catch (PersistenceException exception) {
EppLogger.logError(this.getClass().getName(), "authorize",
exception.getMessage());
throw new Exception("DAO.TECHNICAL_ERROR");
}
catch (Exception e)
{
e.printStackTrace();
EppLogger.logError(this.getClass().getName(), "authorize", e.getMessage());
throw new Exception("DAO.TECHNICAL_ERROR");
}
finally
{
if(session!=null)
{
session.close();
sessionFactory.close();
}
}
return login;
}
driver_class属性中似乎有空格。
<property name="hibernate.connection.driver_class">oracle.jdbc.driver.Oracle Driver</property>
甚至错误消息都表明。
尝试移除空格
<property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
我正在处理Spring Boot项目,突然遇到应用程序无法加载MySQL jdbc的问题。(我编译了一次这个项目,没有改变任何东西) 这是我的pom.xml: 这是我的application.properties: Logcat: MySQL数据库最初是使用hibernate创建的。这些配置工作正常,但我不确定这里的真正问题是什么 编辑:我删除了。m2文件夹并从一开始安装所有依赖项。
我有一个简单的Spring Boot应用程序(通过Spring Roo生成)。 数据库配置如下:
我正在运行以下代码,但是我得到了关于Oracle类名称的错误。我已经用oracle jar文件设置了classpath环境变量,但它不起作用。有人能帮我吗?我不知道还能做什么。我真的很感谢你的帮助 这就是错误:由:java引起。sql。SQLException:无法加载JDBC驱动程序类“oracle”。jdbc。驾驶员OracleDriver's
即使驱动程序类名已定义,我也会收到此错误 Java语言lang.IllegalStateException:无法加载驱动程序类:com。mysql。jdbc。组织的驱动程序。springframework。util。明确肯定state(Assert.java:392)~[spring-core-4.2.1.RELEASE.jar:4.2.1.RELEASE]位于org。springframewor
嘿,伙计们,还有一个问题,下面是信息
问题内容: 我在春季配置了一个netezza db。我在类路径中添加了依赖的nzjdbc.jar 春季配置: 问题答案: 将放入您的本地Maven存储库 (在该目录执行这个位于 然后像正常依赖项一样使用它: @请参阅安装第三方JAR的指南