資源簡介
《J2EE項目開發與設計》 彭燦華編著 中國鐵道出版社全書所有章節源碼
代碼片段和文件信息
package?com.ch7.common;
import?java.sql.*;
/**
?*?數據庫連接類
?*/
public?class?Conn?{
Connection?conn?=?null;
Statement?stmt?=?null;
ResultSet?rs?=?null;
/**
?*?加載驅動程序
?*?*/
public?Conn()?{
try?{
Class.forName(“com.mysql.jdbc.Driver“);
}?catch?(java.lang.ClassNotFoundException?e)?{
System.err.println(e.getMessage());
}
}
/**
?*?執行查詢操作:select
?*?*/
public?ResultSet?executeQuery(String?sql)?{
try?{
conn?=?DriverManager
.getConnection(
“jdbc:mysql://localhost:3306/blogdb?useUnicode=true&characterEncoding=UTF-8“
“root“?null);
stmt?=?conn.createStatement();
rs?=?stmt.executeQuery(sql);
}?catch?(SQLException?ex)?{
System.err.println(ex.getMessage());
}
return?rs;
}
/**
?*?執行更新操作:insert、update、delete
?*?*/
public?int?executeUpdate(String?sql)?{
int?result?=?0;
try?{
conn?=?DriverManager
.getConnection(
“jdbc:mysql://localhost:3306/blogdb?useUnicode=true&characterEncoding=UTF-8“
“root“?null);
stmt?=?conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE
ResultSet.CONCUR_READ_ONLY);
result?=?stmt.executeUpdate(sql);
}?catch?(SQLException?ex)?{
result?=?0;
}
return?result;
}
/**
?*?關閉數據庫連接
?*?*/
public?void?close()?{
try?{
if?(rs?!=?null)
rs.close();
}?catch?(Exception?e)?{
e.printStackTrace(System.err);
}
try?{
if?(stmt?!=?null)
stmt.close();
}?catch?(Exception?e)?{
e.printStackTrace(System.err);
}
try?{
if?(conn?!=?null)?{
conn.close();
}
}?catch?(Exception?e)?{
e.printStackTrace(System.err);
}
}
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件????????932??2012-07-16?16:05??J2EE項目開發與設計?彭燦華編著源碼\blog\.classpath
?????文件????????285??2012-07-15?12:27??J2EE項目開發與設計?彭燦華編著源碼\blog\.myme
?????文件???????1277??2012-07-15?15:18??J2EE項目開發與設計?彭燦華編著源碼\blog\.project
?????文件??????11761??2012-07-17?22:18??J2EE項目開發與設計?彭燦華編著源碼\blog\blogdb.sql
?????文件????????330??2012-07-15?12:27??J2EE項目開發與設計?彭燦華編著源碼\blog\.settings\org.eclipse.jdt.core.prefs
?????文件?????????74??2012-07-16?16:06??J2EE項目開發與設計?彭燦華編著源碼\blog\src\fckeditor.properties
?????文件???????1735??2012-07-15?21:46??J2EE項目開發與設計?彭燦華編著源碼\blog\src\com\ch7\common\Conn.java
?????文件???????2312??2012-07-15?15:15??J2EE項目開發與設計?彭燦華編著源碼\blog\src\com\ch7\common\DataConverter.java
?????文件???????3545??2012-07-16?21:11??J2EE項目開發與設計?彭燦華編著源碼\blog\src\com\ch7\common\DataValidator.java
?????文件???????1401??2012-07-15?15:26??J2EE項目開發與設計?彭燦華編著源碼\blog\src\com\ch7\common\MD5.java
?????文件???????2416??2012-07-16?21:09??J2EE項目開發與設計?彭燦華編著源碼\blog\src\com\ch7\common\Utility.java
?????文件???????3677??2012-07-17?20:23??J2EE項目開發與設計?彭燦華編著源碼\blog\src\com\ch7\dal\Blog.java
?????文件???????2195??2012-07-15?14:44??J2EE項目開發與設計?彭燦華編著源碼\blog\src\com\ch7\dal\Class.java
?????文件???????3357??2012-07-17?20:55??J2EE項目開發與設計?彭燦華編著源碼\blog\src\com\ch7\dal\Comment.java
?????文件???????3869??2012-07-17?22:05??J2EE項目開發與設計?彭燦華編著源碼\blog\src\com\ch7\dal\Users.java
?????文件????????989??2012-07-16?15:45??J2EE項目開發與設計?彭燦華編著源碼\blog\src\com\ch7\model\BlogInfo.java
?????文件????????428??2012-07-15?12:57??J2EE項目開發與設計?彭燦華編著源碼\blog\src\com\ch7\model\ClassInfo.java
?????文件????????831??2012-07-15?12:57??J2EE項目開發與設計?彭燦華編著源碼\blog\src\com\ch7\model\CommentInfo.java
?????文件????????672??2012-07-15?12:57??J2EE項目開發與設計?彭燦華編著源碼\blog\src\com\ch7\model\UsersInfo.java
?????文件???????2360??2012-07-17?22:15??J2EE項目開發與設計?彭燦華編著源碼\blog\WebRoot\about.jsp
?????文件???????3213??2012-07-17?22:15??J2EE項目開發與設計?彭燦華編著源碼\blog\WebRoot\blog-information.jsp
?????文件???????2781??2012-07-17?22:15??J2EE項目開發與設計?彭燦華編著源碼\blog\WebRoot\blog-list.jsp
?????文件???????2572??2012-07-17?21:52??J2EE項目開發與設計?彭燦華編著源碼\blog\WebRoot\comment.jsp
?????文件???????3524??2012-07-16?20:57??J2EE項目開發與設計?彭燦華編著源碼\blog\WebRoot\default.css
?????文件???????2780??2012-07-17?22:15??J2EE項目開發與設計?彭燦華編著源碼\blog\WebRoot\index.jsp
?????文件????????400??2012-07-17?19:56??J2EE項目開發與設計?彭燦華編著源碼\blog\WebRoot\logout.jsp
?????文件???????4178??2012-07-17?22:15??J2EE項目開發與設計?彭燦華編著源碼\blog\WebRoot\register.jsp
?????文件??????13927??2012-07-16?16:04??J2EE項目開發與設計?彭燦華編著源碼\blog\WebRoot\fckeditor\fckconfig.js
?????文件??????13201??2012-07-16?16:04??J2EE項目開發與設計?彭燦華編著源碼\blog\WebRoot\fckeditor\fckpackager.xm
?????文件???????3450??2012-07-16?16:04??J2EE項目開發與設計?彭燦華編著源碼\blog\WebRoot\fckeditor\fckst
............此處省略681個文件信息
評論
共有 條評論