⑴ 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语句
可以移植所有数据库