當前位置:首頁 » 編程語言 » sshsql查詢
擴展閱讀
webinf下怎麼引入js 2023-08-31 21:54:13
堡壘機怎麼打開web 2023-08-31 21:54:11

sshsql查詢

發布時間: 2022-12-09 16:50:07

⑴ SSH 框架+ orcal怎麼用sql實現頁面查詢分頁

給你一段
/**
* 實現分頁查詢
* @param offset 開始索引 start:0
* @param length 查詢長度
* @return
*/
public List getListForPage4SQL(final String sql, final int offset, final int length) {
List retList = getHibernateTemplate().executeFind(new HibernateCallback() {
public Object doInHibernate(Session session) throws HibernateException, SQLException {
Query query = session.createSQLQuery(sql);
query.setFirstResult(offset);
query.setMaxResults(length);
List list = query.list();
return list;
}
});
return retList;
}

⑵ ssh使用hibernate進行sql查詢問題

as col_0_0_這是hibernate內部框架實現,也就是hibernate.dialect。他會把你hql轉換sql,主要是根據不同資料庫做變化,省去你修改的麻煩。

List<Score_detail> sdList = (List<Score_detail>) getSession().createQuery(hql).list();

這樣查詢出來,然後遍歷list,後用sd.getDep...就能取得你要的欄位。

⑶ ssh中的資料庫查詢語句該怎麼寫

您好,這樣的:
在applicationContext.xml中配置
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<bean id="palceHolderConfig"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"
abstract="false" singleton="true" lazy-init="default"
autowire="default" dependency-check="default">
<property name="location">
<value>classpath:init.properties</value>
</property>
</bean>
<!--c3p0數據源配置-->
<bean id="dataSource"
class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close" dependency-check="default">
<property name="driverClass">
<value>${dataSource.driver}</value>
</property>
<property name="jdbcUrl">
<value>${dataSource.jdbcUrl}</value>
</property>
<property name="user">
<value>${dataSource.user}</value>
</property>
<property name="password">
<value>${dataSource.password}</value>
</property>

<property name="acquireIncrement">
<value>${dataSource.acquireIncrement}</value>
</property>
<property name="minPoolSize">
<value>${dataSource.minPoolSize}</value>
</property>
<property name="maxPoolSize">
<value>${dataSource.maxPoolSize}</value>
</property>
<property name="maxIdleTime">
<value>${dataSource.maxIdleTime}</value>
</property>
<property name="idleConnectionTestPeriod">
<value>${dataSource.idleConnectionTestPeriod}</value>
</property>

</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource" />
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.MySQLDialect
</prop>
<!-- 顯示sql語句 -->
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
<property name="mappingResources">
<list>
<value>com/vo/Customer.hbm.xml</value>
<value>com/vo/Engineer.hbm.xml</value>
<value>com/vo/Repairplant.hbm.xml</value>
<value>com/vo/Proct.hbm.xml</value>
<value>com/vo/Archives.hbm.xml</value>
<value>com/vo/Account.hbm.xml</value>
<value>com/vo/User.hbm.xml</value></list>
</property>

</bean>
<bean id="engineerDAO" class="com..impl.EngineerDAO">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
<bean id="repairplantDAO" class="com..impl.RepairplantDAO">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
<bean id="proctDAO" class="com..impl.ProctDAO">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
<bean id="archivesDAO" class="com..impl.ArchivesDAO">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
<bean id="accountDAO" class="com..impl.AccountDAO">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
<bean id="userDAO" class="com..impl.UserDAO">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>

<bean id="customerDAO" class="com..impl.CustomerDAO">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>

</beans>
這樣就可以在調試的時候顯示sql語句了。

⑷ ssh 對數據表查詢出錯。警告: SQL Error: 1064, SQLState: 42000

CREATE TABLE #order ( id varchar(30) NOT NULL, username varchar(10) NOT NULL, proctid int NOT NULL, ordertime time NOT NULL, num int NOT NULL, state int NOT NULL, PRIMARY KEY (id))

這樣就ok了,不明白可追問

⑸ ssh框架用sql查詢出來的一個list如何在頁面顯示

el表達式應該能搞定吧