日期:2014-05-18 浏览次数:20990 次
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
<property name="driverClass">
<value>net.sourceforge.jtds.jdbc.Driver</value>
</property>
<property name="jdbcUrl">
<value>jdbc:jtds:sqlserver://192.168.10.10:1432/suo</value>
</property>
<property name="user">
<value>sa</value>
</property>
<property name="password">
<value>sa</value>
</property>
<property name="minPoolSize">
<value>5</value>
</property>
<property name="maxPoolSize">
<value>50</value>
</property>
<property name="acquireIncrement">
<value>2</value>
</property>
<property name="idleConnectionTestPeriod">
<value>60</value>
</property>
<property name="acquireRetryAttempts">
<value>30</value>
</property>
<property name="maxIdleTime">
<value>30</value>
</property>
<property name="initialPoolSize">
<value>6</value>
</property>
<property name="maxStatements">
<value>0</value>
</property>
</bean>
import java.sql.CallableStatement;
import java.sql.Connection;
import java.util.List;
import java.util.Map;
import com.login.vo.Sd_accountVo;
import com.login.vo.chargeListVo;
import com.login.vo.planrateVO;
import org.springframework.jdbc.core.support.JdbcDaoSupport;
import com.login.dao.ILoginDAO;
public class LoginDAO extends JdbcDaoSupport implements ILoginDAO
{
public List<Map> Query(String sql) throws Exception
{
return this.getJdbcTemplate().queryForList(sql);
}
public Connection getc()
{
Connection c= null;
try{
c = this.getJdbcTemplate().getDataSource().getConnection();
}catch(Exception e)
{
e.printStackTrace();
}
return c;
}
//Connection c =getc();
public boolean Update(String ...sql) throws Exception
{
for(String s : sql)
{
//System.out.println("what's up?"+s);
if(!s.equals(""))
this.getJdbcTemplate().update(s);
}
return true;
}
public boolean execProdu(Sd_accountVo sd,String produName,String usercode)throws Exception
{
boolean t = false ;
CallableStatement call=null;
try{
call = getc().prepareCall
("{CALL "+produName+"(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)}");
call.setString(23, sd.getSim());
...
call.executeUpdate();
//call.getMoreResults(4);
t=true;
}catch(Exception e)
{
e.printStackTrace();
//t=false;
}finally
{
call.close();
}
return t;
}