zoukankan
html css js c++ java
jsp+mysql 数据库操作
package
test;
import
java.sql.
*
;
public
class
Conn
{
static
String data
=
"
jdbc:mysql://localhost/first
"
;
static
java.sql.Statement st;
public
static
void
databaseconnect()
{
//
函数用于 连接数据库
try
{
Class.forName(
"
com.mysql.jdbc.Driver
"
);
Connection conn
=
DriverManager.getConnection(data,
"
root
"
,
"
root
"
);
st
=
conn.createStatement();
}
catch
(Exception e)
{
System.out.println(
"
异常:
"
+
e.toString());
}
}
public
static
String pwquery(String name)
{
databaseconnect();
String inname
=
name;
String pw
=
""
;
ResultSet rs
=
null
;
try
{
rs
=
((java.sql.Statement) st).executeQuery(
"
select * from test2 where name='
"
+
name
+
"
'
"
);
while
(rs.next())
{
pw
=
rs.getString(
"
pass
"
);
}
rs.close();
st.close();
//
pw="abc";
}
catch
(SQLException e)
{
e.printStackTrace();
}
return
pw;
}
}
<?
xml version="1.0" encoding="gb2312"
?>
<%
@ page language
=
"
java
"
contentType
=
"
text/html; charset=gb2312
"
%>
<%
@page import
=
"
test.Conn
"
%>
<!
DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
>
<
html
xmlns
="http://www.w3.org/1999/xhtml"
>
<
head
>
<
meta
http-equiv
="Content-Type"
content
="text/html; charset=ISO-8859-1"
/>
<
title
>
test
</
title
>
</
head
>
<
body
>
<%
String
temp
=
(
String
)session.getValue(
"
login
"
);
temp
=
Conn.pwquery(
"
admin
"
);
//
out.print(temp);
out.print(temp);
%>
</
body
>
</
html
>
注意把
tomcat\common\lib
添加
mysql-connector-java-5.0.8-bin.jar
查看全文
相关阅读:
解决Could not load file or assembly CefSharp.Core.dll的问题
操作AppConfig.xml中AppSettings对应值字符串
SqlServer根据时段统计数据
Jquery Validation 多按钮,多表单,分组验证
HDU 4630 No Pain No Game 线段树 和 hdu3333有共同点
二叉查找树模板
五边形数定理
HDU 4651 Partition 整数划分,可重复情况
CSU 1114 平方根大搜索 java大数
hdu 4869 Turn the pokers
原文地址:https://www.cnblogs.com/gwazy/p/953622.html
最新文章
单调队列 BZOJ 2096 [Poi2010]Pilots
贪心 NOIP2013 花匠
动态规划入门 洛谷P2409 Y的积木
树形DP 洛谷P1272 道路重建
[BZOJ2527][Poi2011]Meteors
[BZOJ1089][SCOI2003]严格n元树
[BZOJ2738]矩阵乘法
[BZOJ1072][SCOI2007]排列perm
[BZOJ3594][Scoi2014]方伯伯的玉米田
[BZOJ2591][Usaco 2012 Feb]Nearby Cows
热门文章
[BZOJ1537][POI2005]Aut- The Bus
[BZOJ2199][Usaco2011 Jan]奶牛议会
[BZOJ1079][SCOI2008]着色方案
[BZOJ1098][POI2007]办公楼biu
codeforeces 845B
一名在校学生关于阅读书籍《梦断代码》的美好计划
加密工具类
使用CefSharp的一些需要注意的点
CefSharp的一些初始化操作
使用CefSharp跳转页面不弹出页面:
Copyright © 2011-2022 走看看