資源簡介
大學城體育信息管理系統,有文檔有源碼,內有數據庫文件和數據庫備份還原方案

代碼片段和文件信息
package?com.godtree.dao;
import?java.sql.Connection;
import?java.sql.DriverManager;
import?java.sql.PreparedStatement;
import?java.sql.ResultSet;
import?java.sql.SQLException;
import?com.godtree.model.User;
public?class?InfoDao?{
String?url=“jdbc:mysql://localhost/sportAlliance?useUnicode=true&characterEncoding=UTF-8“;
String?userName=“root“;
String?passWord=“hideapple“;
Connection?con=null;
ResultSet?rs=null;
PreparedStatement?preparedStatement=null;
public?InfoDao()
{
???? try{
???? Class.forName(“com.mysql.jdbc.Driver“);
???? System.out.println(“數據庫連接包加載成功!“);
???? }catch(ClassNotFoundException?e){
???? System.err.println(“con():“+e.getMessage());
???? }
????}
public?void?update(String?habbiesString?sexString?headImgint?id){
try?{
con=DriverManager.getConnection(urluserNamepassWord);
preparedStatement?=?con.prepareStatement(“update?info?set?hobbies=?sex=?headImg=??where?id=?“);
preparedStatement.setString(1habbies);
preparedStatement.setString(2sex);
preparedStatement.setString(3headImg);
preparedStatement.setInt(4id);
preparedStatement.execute();
}?catch?(SQLException?e)?{
//?TODO?Auto-generated?catch?block
e.printStackTrace();
}
}
public?int?insert(String?habbiesString?sexString?headImgint?schoolid)?{
try?{
con=DriverManager.getConnection(urluserNamepassWord);
preparedStatement?=?con.prepareStatement(“insert?into?info(hobbiessexheadImgschool_id)?values(????)“);
preparedStatement.setString(1habbies);
preparedStatement.setString(2sex);
preparedStatement.setString(3headImg);
preparedStatement.setInt(4schoolid);
preparedStatement.execute();
/*
這里的測試讓我知道了preparedStatement.execute()如果有返回值的話就是true如果沒有就是flase
System.out.println(“執行結果:“+preparedStatement.execute());
*/
int?ret_id=0;
ResultSet?rs?=?preparedStatement.executeQuery(“select?LAST_INSERT_ID()“);
if?(rs.next())?ret_id?=?rs.getInt(1);
System.out.println(“剛插入數據的id是“+ret_id);
System.out.println(“數據庫關閉“);
return?ret_id;
}?catch?(SQLException?e)?{
//?TODO?Auto-generated?catch?block
e.printStackTrace();
return?0;
}
}
public?String?existInfo(int?id)?{
try?{
con=DriverManager.getConnection(urluserNamepassWord);
preparedStatement?=?con.prepareStatement(“select?*?from?info?where?id=?“);
preparedStatement.setInt(1id);
rs=preparedStatement.executeQuery();
if?(rs.next())?{
return?“已經有了“;
}
else?{
return?“還沒有“;
}
}?catch?(SQLException?e)?{
return?“查詢報錯“;
}
}
public?ResultSet?getFirst(int?id)?{
try?{
con=DriverManager.getConnection(urluserNamepassWord);
preparedStatement?=?con.prepareStatement(“select?*?from?info?where?id=?“);
preparedStatement.setInt(1id);
rs=preparedStatement.executeQuery();
rs.next();
//注意這里
return?rs;
}?catch?(SQLException?e)?{
//?TODO?Auto-generated?catch?block
return?null;
}
}
public?int?getSchoolId(int?id)?{
try?{
con=Dri
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2015-07-11?08:22??軟件工程課程設計\
?????目錄???????????0??2015-07-09?23:34??軟件工程課程設計\源碼\
?????目錄???????????0??2015-07-11?08:22??軟件工程課程設計\源碼\jspdemo\
?????文件????????1219??2015-01-17?09:00??軟件工程課程設計\源碼\jspdemo\.classpath
?????文件????????1004??2015-01-17?08:58??軟件工程課程設計\源碼\jspdemo\.project
?????目錄???????????0??2015-07-05?21:40??軟件工程課程設計\源碼\jspdemo\.settings\
?????文件?????????491??2015-01-17?08:58??軟件工程課程設計\源碼\jspdemo\.settings\.jsdtscope
?????文件?????????357??2015-01-17?08:58??軟件工程課程設計\源碼\jspdemo\.settings\org.eclipse.jdt.core.prefs
?????文件?????????465??2015-01-17?08:58??軟件工程課程設計\源碼\jspdemo\.settings\org.eclipse.wst.common.component
?????文件?????????335??2015-01-17?09:00??軟件工程課程設計\源碼\jspdemo\.settings\org.eclipse.wst.common.project.facet.core.xm
?????文件??????????49??2015-01-17?08:58??軟件工程課程設計\源碼\jspdemo\.settings\org.eclipse.wst.jsdt.ui.superType.container
?????文件???????????6??2015-01-17?08:58??軟件工程課程設計\源碼\jspdemo\.settings\org.eclipse.wst.jsdt.ui.superType.name
?????目錄???????????0??2015-07-05?21:40??軟件工程課程設計\源碼\jspdemo\WebContent\
?????文件????????8249??2015-01-19?17:24??軟件工程課程設計\源碼\jspdemo\WebContent\Initialization.sql
?????目錄???????????0??2015-07-05?21:40??軟件工程課程設計\源碼\jspdemo\WebContent\me
?????文件??????????39??2015-01-17?08:58??軟件工程課程設計\源碼\jspdemo\WebContent\me
?????目錄???????????0??2015-07-05?21:40??軟件工程課程設計\源碼\jspdemo\WebContent\WEB-INF\
?????目錄???????????0??2015-07-05?21:40??軟件工程課程設計\源碼\jspdemo\WebContent\WEB-INF\lib\
?????文件??????414240??2015-01-20?14:10??軟件工程課程設計\源碼\jspdemo\WebContent\WEB-INF\lib\jstl-1.2.jar
?????文件??????116799??2015-01-17?08:58??軟件工程課程設計\源碼\jspdemo\WebContent\WEB-INF\lib\junit4.4.jar
?????文件??????118286??2015-01-17?08:58??軟件工程課程設計\源碼\jspdemo\WebContent\WEB-INF\lib\log4j-api-2.0.jar
?????文件??????781279??2015-01-17?08:58??軟件工程課程設計\源碼\jspdemo\WebContent\WEB-INF\lib\log4j-core-2.0.jar
?????文件??????434812??2015-01-17?08:58??軟件工程課程設計\源碼\jspdemo\WebContent\WEB-INF\lib\mail.jar
?????文件??????832960??2015-01-17?08:58??軟件工程課程設計\源碼\jspdemo\WebContent\WEB-INF\lib\mysql-connector-java-5.1.22-bin.jar
?????文件??????393259??2015-01-20?14:10??軟件工程課程設計\源碼\jspdemo\WebContent\WEB-INF\lib\standard-1.1.2.jar
?????文件?????????360??2015-01-17?08:58??軟件工程課程設計\源碼\jspdemo\WebContent\WEB-INF\log4j.xm
?????文件?????????419??2015-01-20?22:45??軟件工程課程設計\源碼\jspdemo\WebContent\WEB-INF\web.xm
?????目錄???????????0??2015-07-05?21:40??軟件工程課程設計\源碼\jspdemo\WebContent\bootstrap\
?????目錄???????????0??2015-07-05?21:40??軟件工程課程設計\源碼\jspdemo\WebContent\bootstrap\css\
?????文件???????21368??2015-01-17?08:58??軟件工程課程設計\源碼\jspdemo\WebContent\bootstrap\css\bootstrap-theme.css
?????文件???????23071??2015-01-17?08:58??軟件工程課程設計\源碼\jspdemo\WebContent\bootstrap\css\bootstrap-theme.css.map
............此處省略143個文件信息
- 上一篇:SQLite在android中實現增刪改查小
- 下一篇:JAVA類小游戲集合壓縮包
評論
共有 條評論