我正在尝试通过休眠将一些数据插入到 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) 假设当用户访问我的网站时,他会看到之前存储在数据库中的大量图像.我知道如何在JSP Scriptlet中做到这一点,并且我还知道当用户使用servlet提交表单时如何从JSTL中的数据库中获取和检索数据.但是我不知道如何在没有用户提交表单的情况下在JSTL中执行此操作.