小编use*_*470的帖子

如何在 hibernate.cfg.xml 中连接 postgresql

我正在尝试通过休眠将一些数据插入到 postgresql 中。但是,关于使用postgresql配置hibernate的教程并不多(我知道,它应该类似于mysql =))

src/main/resources/hibernate.cfg.xml

<hibernate-configuration>
<session-factory>
<property name="connection.driver_class">org.postgresql.Driver</property>
<property name="connection.url">jdbc:postgresql://127.0.0.1:5432/myDatabase</property>
<property name="connection.username">myUser</property>
<property name="connection.password">myPassword</property>

<!-- JDBC connection pool (use the build-in) -->
<property name="connection.pool_size">1</property>
<!-- SQL dialect -->
<property name="dialect">org.hibernate.dialect.PostgreSQLDialect</property>
<property name="cache.provider_class">org.hibernate.cache.HashtableCacheProvider</property>
<property name="transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</property>

<!-- thread is the short name for org.hibernate.context.ThreadLocalSessionContext -->
<property name="current_session_context_class">thread</property>

<!-- Set "true" to show SQL statements -->
<property name="hibernate.show_sql">true</property>

<!-- mapping class using annotation -->
<mapping class="com.hib.entities.Student"></mapping>
</session-factory>

</hibernate-configuration>
Run Code Online (Sandbox Code Playgroud)

源代码/主/Java/

package com.hib.init;

import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
import org.hibernate.service.ServiceRegistry;
import org.hibernate.service.ServiceRegistryBuilder;

public class Hibernateutil …
Run Code Online (Sandbox Code Playgroud)

java database postgresql spring hibernate

6
推荐指数
1
解决办法
2万
查看次数

从数据库中检索图像并使用JSTL在JSP中显示它

假设当用户访问我的网站时,他会看到之前存储在数据库中的大量图像.我知道如何在JSP Scriptlet中做到这一点,并且我还知道当用户使用servlet提交表单时如何从JSTL中的数据库中获取和检索数据.但是我不知道如何在没有用户提交表单的情况下在JSTL中执行此操作.

database jsp jstl

2
推荐指数
1
解决办法
2万
查看次数

标签 统计

database ×2

hibernate ×1

java ×1

jsp ×1

jstl ×1

postgresql ×1

spring ×1