-
大小: 19KB文件类型: .rar金币: 1下载: 0 次发布日期: 2021-05-14
- 语言: 数据库
- 标签:
资源简介
Servlet实现对SQLServer数据库的增删改查
代码片段和文件信息
//sql_data.java
package edu.hwadee.pro.bean;
import java.sql.*;
public class sql_data {
String sDBDriver = “com.microsoft.sqlserver.jdbc.SQLServerDriver“;
String url = “jdbc:sqlserver://localhost:1433;DatabaseName=test“;
String user = “sa“;
String password = “SQLServer2012“;
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
public sql_data() {
try {
Class.forName(sDBDriver);
} catch (java.lang.ClassNotFoundException e) {
System.err.println(“sql_data(): “ + e.getMessage());
}
}
public void executeInsert(String sql) {
try {// conn = DriverManager.getConnection(urluserpassword);
conn = DriverManager.getConnection(url user password);
stmt = conn.createStatement();
stmt.executeUpdate(sql);
stmt.close();
conn.close();
} catch (SQLException ex) {
System.err.println(“sql_data.executeUpdate:“ + ex.getMessage());
}
}
public ResultSet executeQuery(String sql) {
try {
conn = DriverManager.getConnection(url user password);
stmt = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE
ResultSet.CONCUR_READ_ONLY);
rs = stmt.executeQuery(sql);
} catch (SQLException ex) {
System.err.println(“sql_data.executeQuery:“ + ex.getMessage());
}
return rs;
}
public void executeUpdate(String sql) {
try {
conn = DriverManager.getConnection(url user password);
stmt = conn.createStatement();
stmt.executeUpdate(sql);
stmt.close();
conn.close();
} catch (SQLException ex) {
System.err.println(“aq.executeQuery: “ + ex.getMessage());
}
}
public void executeDelete(String sql) {
try {
conn = DriverManager.getConnection(url user password);
stmt = conn.createStatement();
stmt.executeUpdate(sql);
stmt.close();
conn.close();
} catch (SQLException ex) {
System.err.println(“sql_data.executeDelete:“ + ex.getMessage());
}
}
public void closeStmt() {
try {
stmt.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
public void closeConn() {
try {
conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 362 2015-06-24 14:07 Servlet实现对SQLServer数据库的增删改查\0623p\.classpath
文件 288 2015-06-24 14:07 Servlet实现对SQLServer数据库的增删改查\0623p\.myme
文件 1411 2015-06-24 14:07 Servlet实现对SQLServer数据库的增删改查\0623p\.project
文件 500 2015-06-24 14:07 Servlet实现对SQLServer数据库的增删改查\0623p\.settings\.jsdtscope
文件 330 2015-06-24 14:07 Servlet实现对SQLServer数据库的增删改查\0623p\.settings\org.eclipse.jdt.core.prefs
文件 49 2015-06-24 14:07 Servlet实现对SQLServer数据库的增删改查\0623p\.settings\org.eclipse.wst.jsdt.ui.superType.container
文件 6 2015-06-24 14:07 Servlet实现对SQLServer数据库的增删改查\0623p\.settings\org.eclipse.wst.jsdt.ui.superType.name
文件 2183 2015-06-24 14:07 Servlet实现对SQLServer数据库的增删改查\0623p\src\edu\hwadee\pro\bean\sql_data.java
文件 2742 2015-06-24 14:07 Servlet实现对SQLServer数据库的增删改查\0623p\src\edu\hwadee\pro\control\addServlet.java
文件 2509 2015-06-24 14:07 Servlet实现对SQLServer数据库的增删改查\0623p\src\edu\hwadee\pro\control\delServlet.java
文件 2778 2015-06-24 14:07 Servlet实现对SQLServer数据库的增删改查\0623p\src\edu\hwadee\pro\control\updateServlet.java
文件 559 2015-06-24 14:07 Servlet实现对SQLServer数据库的增删改查\0623p\WebRoot\add.jsp
文件 1979 2015-06-24 14:07 Servlet实现对SQLServer数据库的增删改查\0623p\WebRoot\index.jsp
文件 36 2015-06-24 14:07 Servlet实现对SQLServer数据库的增删改查\0623p\WebRoot\me
文件 992 2015-06-24 14:07 Servlet实现对SQLServer数据库的增删改查\0623p\WebRoot\update.jsp
文件 3004 2015-06-24 14:07 Servlet实现对SQLServer数据库的增删改查\0623p\WebRoot\WEB-INF\classes\edu\hwadee\pro\bean\sql_data.class
文件 2415 2015-06-24 14:07 Servlet实现对SQLServer数据库的增删改查\0623p\WebRoot\WEB-INF\classes\edu\hwadee\pro\control\addServlet.class
文件 2271 2015-06-24 14:07 Servlet实现对SQLServer数据库的增删改查\0623p\WebRoot\WEB-INF\classes\edu\hwadee\pro\control\delServlet.class
文件 2490 2015-06-24 14:07 Servlet实现对SQLServer数据库的增删改查\0623p\WebRoot\WEB-INF\classes\edu\hwadee\pro\control\updateServlet.class
文件 1716 2015-06-24 14:07 Servlet实现对SQLServer数据库的增删改查\0623p\WebRoot\WEB-INF\web.xm
目录 0 2015-06-24 14:07 Servlet实现对SQLServer数据库的增删改查\0623p\WebRoot\WEB-INF\classes\edu\hwadee\pro\bean
目录 0 2015-06-24 14:07 Servlet实现对SQLServer数据库的增删改查\0623p\WebRoot\WEB-INF\classes\edu\hwadee\pro\control
目录 0 2015-06-24 14:07 Servlet实现对SQLServer数据库的增删改查\0623p\WebRoot\WEB-INF\classes\edu\hwadee\pro
目录 0 2015-06-24 14:07 Servlet实现对SQLServer数据库的增删改查\0623p\src\edu\hwadee\pro\bean
目录 0 2015-06-24 14:07 Servlet实现对SQLServer数据库的增删改查\0623p\src\edu\hwadee\pro\control
目录 0 2015-06-24 14:07 Servlet实现对SQLServer数据库的增删改查\0623p\WebRoot\WEB-INF\classes\edu\hwadee
目录 0 2015-06-24 14:07 Servlet实现对SQLServer数据库的增删改查\0623p\src\edu\hwadee\pro
目录 0 2015-06-24 14:07 Servlet实现对SQLServer数据库的增删改查\0623p\WebRoot\WEB-INF\classes\edu
目录 0 2015-06-24 14:07 Servlet实现对SQLServer数据库的增删改查\0623p\src\edu\hwadee
目录 0 2015-06-24 14:07 Servlet实现对SQLServer数据库的增删改查\0623p\WebRoot\WEB-INF\classes
............此处省略13个文件信息
- 上一篇:段成华数字集成作业
- 下一篇:LabVIEW单通道数据采集保存数据库
评论
共有 条评论