資源簡介
此商城是基于jsp+mysql開發(fā),可以實現(xiàn)前臺的展示以及后臺數(shù)據(jù)的連接,進行數(shù)據(jù)的增刪改查,對自身的代碼量有一定的提升。

代碼片段和文件信息
package?rcm.dao;
import?java.sql.Connection;
import?java.sql.DriverManager;
import?java.sql.PreparedStatement;
import?java.sql.ResultSet;
import?java.sql.SQLException;
import?java.sql.Statement;
public?class?DatabaseUtils?{
public?static?Connection?getConnection(){
?
Connection?conn?=?null;
try?
{
try?{
Class.forName(“com.mysql.jdbc.Driver“).newInstance();
}?catch?(InstantiationException?e)?{e.printStackTrace();
}?catch?(IllegalAccessException?e)?{e.printStackTrace();}
conn=?DriverManager.getConnection(“jdbc:mysql://localhost:3306/rcm?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull““root““root“);//1q2w3e4r5t?
}catch?(ClassNotFoundException?e)?{
e.printStackTrace();
}catch?(SQLException?e)?{
e.printStackTrace();
}
return?conn;
}
public?static?Statement?createStmt(Connection?conn)?{
Statement?stmt?=?null;
try?
{
stmt?=?conn.createStatement();
}?
catch?(SQLException?e)?
{
e.printStackTrace();
}
return?stmt;
}
public?static?ResultSet?executeQuery(Statement?stmt?String?sql)?{
ResultSet?rs?=?null;
try?
{
rs?=?stmt.executeQuery(sql);
}?
catch?(SQLException?e)?
{
e.printStackTrace();
}
return?rs;
}
public?static?ResultSet?executeQuery(PreparedStatement?preparedstmt)
{
ResultSet?rs?=?null;
try?{
rs?=?preparedstmt.executeQuery();
}?catch?(SQLException?e)?{
//?TODO?Auto-generated?catch?block
e.printStackTrace();
}
return?rs;
}
public?static?PreparedStatement?prepareStmt(Connection?conn?String?sql)?{
PreparedStatement?pstmt?=?null;
try?{
pstmt?=?(PreparedStatement)?conn.prepareStatement(sql);
}catch?(SQLException?e)?{
e.printStackTrace();
}
return?pstmt;
}
public?static?void?close(Connection?conn)?{
if?(conn?!=?null)?{
try?{
conn.close();
}?catch?(SQLException?e)?{
e.printStackTrace();
}
}
}
public?static?void?close(Statement?stmt)?{
if?(stmt?!=?null)?
{
try?
{
stmt.close();
}?
catch?(SQLException?e)?
{
e.printStackTrace();
}
}
}
public?static?void?close(ResultSet?rs)?
{
if?(rs?!=?null)?
{
try?{
rs.close();
}
catch?(SQLException?e)?
{
e.printStackTrace();
}
}
}
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????1800??2016-05-19?17:32??shopping\rcm\.classpath
?????文件????????282??2016-02-07?11:52??shopping\rcm\.myme
?????文件???????1746??2016-02-07?15:00??shopping\rcm\.project
?????文件????????500??2016-02-07?11:52??shopping\rcm\.settings\.jsdtscope
?????文件?????????74??2016-05-13?18:40??shopping\rcm\.settings\com.genuitec.eclipse.core.prefs
?????文件????????247??2016-05-19?17:32??shopping\rcm\.settings\com.genuitec.eclipse.migration.prefs
?????文件????????364??2016-02-07?11:52??shopping\rcm\.settings\org.eclipse.jdt.core.prefs
?????文件????????535??2016-05-19?17:32??shopping\rcm\.settings\org.eclipse.wst.common.component
?????文件????????359??2016-05-19?17:32??shopping\rcm\.settings\org.eclipse.wst.common.project.facet.core.xm
?????文件?????????49??2016-02-07?11:52??shopping\rcm\.settings\org.eclipse.wst.jsdt.ui.superType.container
?????文件??????????6??2016-02-07?11:52??shopping\rcm\.settings\org.eclipse.wst.jsdt.ui.superType.name
?????文件?????????25??2016-05-19?17:32??shopping\rcm\src\me
?????文件???????2373??2016-05-20?14:14??shopping\rcm\src\rcm\dao\Databa
?????文件???????5541??2016-02-17?11:05??shopping\rcm\src\rcm\dao\ProductDao.java
?????文件???????1301??2016-02-17?11:44??shopping\rcm\src\rcm\dao\UserDao.java
?????文件????????506??2016-02-07?12:44??shopping\rcm\src\rcm\entity\ClassfiyProduct.java
?????文件????????488??2016-02-07?12:42??shopping\rcm\src\rcm\entity\Classify.java
?????文件????????922??2016-02-08?12:31??shopping\rcm\src\rcm\entity\Frequency.java
?????文件???????1730??2016-02-09?17:33??shopping\rcm\src\rcm\entity\Product.java
?????文件????????456??2016-02-07?12:45??shopping\rcm\src\rcm\entity\User.java
?????文件???????1933??2016-02-17?11:00??shopping\rcm\src\rcm\servlet\FindAllProducts.java
?????文件???????1023??2016-02-17?11:01??shopping\rcm\src\rcm\servlet\IndexServlet.java
?????文件???????1301??2016-02-09?16:49??shopping\rcm\src\rcm\servlet\LoginServlet.java
?????文件???????1020??2016-02-09?20:13??shopping\rcm\src\rcm\servlet\LogoutServlet.java
?????文件???????1473??2016-02-17?10:59??shopping\rcm\src\rcm\servlet\ProductDetailServlet.java
?????文件???????1285??2016-02-17?11:02??shopping\rcm\src\rcm\servlet\RegistServlet.java
?????文件????????991??2014-03-01?10:38??shopping\rcm\WebRoot\css\context.css
?????文件???????4158??2015-02-19?12:20??shopping\rcm\WebRoot\css\order.css
?????文件???????9182??2015-02-14?10:05??shopping\rcm\WebRoot\css\shopping_vehicle.css
?????文件??????15342??2015-02-14?00:10??shopping\rcm\WebRoot\css\T2_common.css
............此處省略122個文件信息
評論
共有 條評論