Sex Varchar 5 内容来自www.paper51.com
yes 内容来自www.paper51.com Mail http://www.paper51.com Varchar 内容来自论文无忧网 www.paper51.com
5 http://www.paper51.com yes http://www.paper51.com
paper51.com
Varchar copyright paper51.com 15 内容来自www.paper51.com yes paper51.com Tel paper51.com Varchar 内容来自论文无忧网 www.paper51.com 15 内容来自论文无忧网 www.paper51.com yes http://www.paper51.com Job copyright paper51.com Varchar copyright paper51.com 20 内容来自论文无忧网 www.paper51.com yes copyright paper51.com 3.5.3物理结构设计要点 paper51.com 系统数据库采用MYSQL。今天的商业环境要求不同类型的数据库解决方案。性能、可伸缩性及可靠性是基本要求,MYSQL 给数据管理与分析带来了灵活性。从数据管理和分析角度看,MYSQL可以作为一个完备的数据库和数据分析包。作为重要的基准测试可伸缩性和速度奖的记录保持者,MYSQL 是一个具备完全功能支持的数据库产品,提供了对可扩展标记语言 (XML) 的核心支持以及在 Internet 上和防火墙外进行查询的能力。 http://www.paper51.com
3.5.4数据结构与程序的关系 内容来自www.paper51.com 服务器端程序采用JDBC来访问数据库: copyright paper51.com ---------------------------------------------------------------------------------------------------------------- paper51.com Class.forName("com.mysql.jdbc.Driver"); http://www.paper51.com Connection con =DriverManager.getConnection("jdbc:mysql://"+"localhost"+"/"+numb1,"root",""); copyright paper51.com ---------------------------------------------------------------------------------------------------------------- 内容来自www.paper51.com
上面两条Java语句完成数据库的连接,而下面几条语句则完成最基本的信息数据查询操作。 copyright paper51.com
---------------------------------------------------------------------------------------------------------------- paper51.com packagenumb1.com; http://www.paper51.com importjava.lang.*; paper51.com
importjava.sql.*; copyright paper51.com
public class db{ 内容来自www.paper51.com private Connection con; http://www.paper51.com private Statement st; paper51.com private ResultSet rs; http://www.paper51.com private Stringhost="localhost"; 内容来自www.paper51.com private String user="root"; http://www.paper51.com private String pw=""; 内容来自论文无忧网 www.paper51.com private String db="numb1"; paper51.com
private StringDri="com.mysql.jdbc.Driver"; 内容来自论文无忧网 www.paper51.com private Stringurl="jdbc:mysql://"+host+"/"+db; paper51.com public String getStr(String s){ 内容来自论文无忧网 www.paper51.com
String str=s; 内容来自www.paper51.com
try{ 内容来自www.paper51.com
byte b[]=str.getBytes("ISO-8859-1"); copyright paper51.com str=new String(b); http://www.paper51.com return str; 内容来自论文无忧网 www.paper51.com
} http://www.paper51.com catch(Exceptione){return null;} http://www.paper51.com } copyright paper51.com public Stringgb2iso(String qs){ paper51.com try{ 内容来自论文无忧网 www.paper51.com if (qs == null) return "NULL"; copyright paper51.com else return newString(qs.getBytes("gb2312"),"iso-8859-1"); http://www.paper51.com } http://www.paper51.com
catch(Exceptione){ 内容来自论文无忧网 www.paper51.com System.out.print("gb2iso error:"+e.getMessage()); 内容来自www.paper51.com } copyright paper51.com return"NULL"; http://www.paper51.com } http://www.paper51.com public void close(){//关闭连接 内容来自论文无忧网 www.paper51.com
try{ http://www.paper51.com if(rs!=null)rs.close(); paper51.com }catch(Exceptione){ copyright paper51.com System.out.print("rs"+e.getMessage()); 内容来自论文无忧网 www.paper51.com } 内容来自论文无忧网 www.paper51.com try{ 内容来自www.paper51.com if(st!=null)st.close(); copyright paper51.com }catch(Exceptione){ 内容来自论文无忧网 www.paper51.com System.out.print("st"+e.getMessage()); http://www.paper51.com } copyright paper51.com try{ copyright paper51.com if(con!=null)con.close(); copyright paper51.com }catch(Exceptione){ copyright paper51.com System.out.print("con"+e.getMessage()); paper51.com
} paper51.com
} 内容来自www.paper51.com public ResultSet query(String sql)throwsException{ http://www.paper51.com try{ copyright paper51.com Class.forName(Dri).newInstance(); 内容来自www.paper51.com
con=DriverManager.getConnection(url,user,pw); 内容来自论文无忧网 www.paper51.com st=con.createStatement(); 内容来自www.paper51.com rs=st.executeQuery(sql); copyright paper51.com return rs; paper51.com }catch(SQLException e){ 内容来自www.paper51.com
System.out.print(e.getMessage()); copyright paper51.com
内容来自论文无忧网 www.paper51.com |