資源簡介
基于jsp的圖書管理系統
運用sqlserver連接數據庫
界面友好
易于掌握

代碼片段和文件信息
package?conndb;
import?java.sql.*;
public?class?DbConnBean
{
private?static?Connection?conn;
private?Statement?stmt;
private?ResultSet?rs;
/*********************************************
**函數功能:創建數據庫Statement
**********************************************/
public?void?init(Connection?conn){
try
{
stmt=this.conn.createStatement();
}
catch?(Exception?e)
{
System.out.println(“init:“+e.getMessage());
}
}
/*********************************************
**函數功能:創建數據庫Statement
**********************************************/
public?void?close(){
try
{
if?(rs!=null)
{
rs.close();
}
}
catch?(Exception?e)
{
System.out.println(“rs.close():“+e.getMessage());
}
try
{
if?(stmt!=null)
{
stmt.close();
}
}
catch?(Exception?e)
{
System.out.println(“stmt.close():“+e.getMessage());
}
try
{
if?(conn!=null)
{
conn.close();
}
}
catch?(Exception?e)
{
System.out.println(“conn.close():“+e.getMessage());
}
}
/*********************************************
**函數功能:查詢數據
**********************************************/
public?int?select(String?sql){
int?k=-10;
this.init(this.getConn());
try
{
k=0;
rs=stmt.executeQuery(sql);
if?(rs.next())
{
k=k+1;
}
}
catch?(Exception?e)
{
k=-1;
System.out.println(“select():“+e.getMessage());
this.close();
}
this.close();
return?k;
}
/*********************************************
**函數功能:更新\刪除\插入?數據
**********************************************/
public?int?update(String?sql){
int?k=-10;
this.init(this.getConn());
try
{
k=0;
k=stmt.executeUpdate(sql);
}
catch?(Exception?e)
{
k=-1;
System.out.println(“update():“+e.getMessage());
}
this.close();
return?k;
}
/*********************************************
**函數功能:創建數據庫連接
**********************************************/
public?static?synchronized?Connection?getConn(){
try
{
Class.forName(“sun.jdbc.odbc.JdbcOdbcDriver“);
conn=DriverManager.getConnection(“jdbc:odbc:book“““““);//需要配置數據源,access和sql?server2000都可以連接的
}
catch?(Exception?e)
{
System.out.println(“getConn():“+e.getMessage());
}
return?conn;
}
/*********************************************
**函數功能:做編碼轉換防止中文難亂
**********************************************/
public?String?chStr(String?str){
try
{
byte[]?temp=str.getBytes(“ISO8859-1“);
String?temp2=new?String(temp);
return?temp2;?
}catch(Exception?e){System.out.println(“chStr():“+e.getMessage());}
return?“null“;
}
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件????????340??2009-05-27?14:06??syw\.classpath
?????文件????????294??2011-06-02?18:56??syw\.myme
?????文件???????1413??2011-05-23?20:53??syw\.project
?????文件????????500??2011-05-23?20:53??syw\.settings\.jsdtscope
?????文件????????334??2009-05-27?14:06??syw\.settings\org.eclipse.jdt.core.prefs
?????文件?????????49??2011-05-23?20:53??syw\.settings\org.eclipse.wst.jsdt.ui.superType.container
?????文件??????????6??2011-05-23?20:53??syw\.settings\org.eclipse.wst.jsdt.ui.superType.name
?????文件????1441792??2009-06-10?16:38??syw\data\booklib_Data.MDF
?????文件????1048576??2009-06-10?16:38??syw\data\booklib_Log.LDF
?????文件????????947??2011-06-03?13:21??syw\data\sql.sql
?????文件???????2792??2009-05-27?14:07??syw\src\conndb\DbConnBean.java
?????文件????????425??2009-05-27?14:07??syw\src\DateBean\MyDate.java
?????文件???????1049??2009-06-06?10:06??syw\WebRoot\admin\admin_addadmin.jsp
?????文件???????1539??2009-06-06?20:47??syw\WebRoot\admin\admin_addadmin_post.jsp
?????文件???????1425??2009-06-06?10:12??syw\WebRoot\admin\admin_addnewbook.jsp
?????文件???????1591??2009-06-07?09:19??syw\WebRoot\admin\admin_addnewbook_post.jsp
?????文件???????2046??2009-06-06?10:18??syw\WebRoot\admin\admin_addnewuser.jsp
?????文件???????1514??2009-06-06?20:57??syw\WebRoot\admin\admin_addnewuser_post.jsp
?????文件????????976??2009-06-06?10:31??syw\WebRoot\admin\admin_addnotice.jsp
?????文件????????967??2009-06-06?10:40??syw\WebRoot\admin\admin_addnotice_post.jsp
?????文件???????1362??2009-06-06?20:58??syw\WebRoot\admin\admin_borrowbook.jsp
?????文件???????1385??2009-06-06?22:51??syw\WebRoot\admin\admin_borrowbook_post.jsp
?????文件???????2166??2009-06-06?10:55??syw\WebRoot\admin\admin_changebook.jsp
?????文件???????1232??2009-06-06?10:57??syw\WebRoot\admin\admin_changebook_post.jsp
?????文件???????1223??2009-06-06?11:06??syw\WebRoot\admin\admin_changepwd.jsp
?????文件???????1252??2009-06-06?11:06??syw\WebRoot\admin\admin_changepwd_post.jsp
?????文件???????3367??2009-06-06?11:08??syw\WebRoot\admin\admin_changeuser.jsp
?????文件???????1239??2009-06-01?20:34??syw\WebRoot\admin\admin_changeuser_post.jsp
?????文件????????974??2009-06-06?19:00??syw\WebRoot\admin\admin_deladmin.jsp
?????文件????????799??2009-06-06?18:56??syw\WebRoot\admin\admin_delbook.jsp
............此處省略89個文件信息
- 上一篇:Android計算器小程序
- 下一篇:大學生家教平臺系統Java
評論
共有 條評論