
getHibernateTemplate方法怎么执行sql语句
1个回答
展开全部
获取一个Connection:
Connection conn = getHibernateTemplate().getSessionFactory().openSession().connection();
Statement st=conn.createStatement();
st.execute("select * from tablename");
最后关闭链接:
finally{
try{
if(st!=null)
st.close();
if(conn!=null)
conn.close();
}catch(SQLException e){
System.out.println(e.toString());
}
}
Connection conn = getHibernateTemplate().getSessionFactory().openSession().connection();
Statement st=conn.createStatement();
st.execute("select * from tablename");
最后关闭链接:
finally{
try{
if(st!=null)
st.close();
if(conn!=null)
conn.close();
}catch(SQLException e){
System.out.println(e.toString());
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询