Home >Database >Mysql Tutorial >如何使用JSP连接DB2数据库_MySQL

如何使用JSP连接DB2数据库_MySQL

WBOY
WBOYOriginal
2016-06-01 14:06:531269browse

DB2


import ="java.util.*"
import ="java.io.*"
contentType="text/html; charset=gb2312"
%>


使用Db2数据库





使用JSP连接到Db2数据库


String host="192.1.1.127"; //数据库主机
String database="myweb"; //数据库名
String user="db2admin"; //用户名
String pass="db2admin"; //口令
%> java.sql.Statement sqlStmt; //语句对象
java.sql.ResultSet sqlRst; //结果集对象
try{


out.print ("连接数据库成功!");
%>

//关闭结果集对象
//sqlRst.close();
//关闭语句对象
//sqlStmt.close ();
//关闭数据库连接
sqlConn.close();
}catch (SQLException e)
{ out.print ("连接数据库失败!");
out.print (e);
}
%>

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn