⑴ 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中就是不用hql語句,用sql語句咋么寫
和正常sql 語句一樣
select * from user
⑶ ssh框架開發繼承HibernateDaoSupport實現的增刪改功能,不用寫sql語句。問:具體執行的sql語句在哪
其實數據操作還是在層
只不過通過寫的是hql語句的(當然也可以寫sql),
hibernate是面向對象的資料庫操作
如新增
調用save方法,參數為表所對應的實體對象!
有問題追問,good luck!
⑷ ssh整合中設計3個表sql語句怎麼寫
select c.cid, c.cname, c.bid from a a,b b, c c where a.aid = b.aid and b.bid = c.bid and a.aid = '1'
HQL應該這樣寫,你試試。
⑸ 再怎麼寫:ssh框架,在成想用一條sql語句將資料庫表中的對應記錄刪除:
裡面不是有一個delete方法嗎?你是什麼資料庫......
裡面有一個方法的
如果是SSH 繼承這個 extends HibernateDaoSupport就行了 根據ID刪除
然後在方法裡面寫
public void delThenInsertNewCode(MerchantMpSub merchantMpSub){
this.getHibernateTemplate().delete(merchantMpSub.getID);
}
你這個方法還是在hibernate上面的
public void delThenInsertNewCode(MerchantMpSub merchantMpSub) {
SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
Session session = sessionFactory.openSession();
Transaction tx= session .beginTransaction();
//獲取要刪除的是那一個
merchantMpSub =session.load(MerchantMpSub .class, merchantMpSub.getID);
//刪除獲取的那一個
session .delete(merchantMpSub);
tx.commit();
session .close();
sessionFactory .close();
}
⑹ java ssh框架連接 sql server 的代碼怎麼寫啊 求指教
ssh?
spring spring hibernate?
strus spring hibernate?
⑺ 如何用SSH框架簡單寫一個MySQL的增刪改查。請給出完整代碼。包括配置文件,SQL語句。
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con=null;
Statement st=null;
ResultSet rs=null;
con=DriverManager.getConnection("jdbc:oracle:thin:@127.0.0.1:1521:name", "scott","tiger");
st=con.createStatement();
rs=st.executeQuery(查);
st.executeNonQuety(增、刪、改)
⑻ ssh框架里show_sql在哪裡設置
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource" />
</property>
<property name="hibernateProperties">
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="show_SQL">true</prop>
</props>
</property>
</bean>
⑼ ssh框架中如何拼寫SQL語句
用HQL語句就可以了
這個是hibernate提供的一種sql語句
可以移植所有資料庫