Archive for the ‘hibernate’ Category



hibernate资料整理

In: JAVA| hibernate

5 十一 2006

结合《深入浅出hibernate》
ORM ( Object/Relation Mapping–对象/关系数据库映射 )
主要面向的是MVC的M层,是业务逻辑和数据逻辑关联紧密部分,也就是持久层部分

耦合:即事务之间的关联关系,解耦合:降低两者的关联关系
程序一:

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class update_msg
{
   public boolean update_msg_do(String id,String amount)
{
    Statement stmt=null;
    ResultSet rts=null;
    Connection con=null;
try{
 Class.forName(“org.gjt.mm.mysql.Driver”).newInstance();
   con=DriverManager.getConnection(“localhost”,”qk31″,”test”);
  String updateSQL=”update msg set amount=’”+amount+”‘ where id=’”+id+”‘”;
      stmt=con.createStatement();
      return stmt.executeUpdate(updatesql);
 
}catch(Exception e){
    System.out.println(“连接数据库出错”+e.toString());
}finally{
 
con.close();
stmt.close();
}
 
}
}
 

程序二:增加一个配置的抽象类,方便jdbc以及用户名和数据库之类的灵活性

public abstract class config {
   public String DB_driver=”org.gjt.mm.mysql.Driver”;
   public String DB_name=”qk31″;
   public String DB_passwd=”11111″;
   public String DB_con=”jdbc:mysql://localhost/test?useUnicode=true&characterEncoding=gbk”;
}
 
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class update_msg extends config
{
   public [...]


About this blog

QK31欢迎你的到来.

Photostream

Flash MP3 Player JW

Here is the Music Player. You need to installl flash player to show this cool thing!

search_extends

 

2010年三月
« 二    
1234567
891011121314
15161718192021
22232425262728
293031  

分类目录

标签云


36
Unique
Visitors
Powered By Google Analytics