當前位置:首頁 » 操作系統 » jsp源碼資料庫

jsp源碼資料庫

發布時間: 2022-09-23 07:30:14

1. jsp登陸界面源代碼

login.jsp文件

<%@ page language="java" contentType="text/html; charset=GB18030"

pageEncoding="GB18030"%>

<%@ page import="java.util.*" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>

<head>

<title>登錄頁面</title>

</head>

<body>

<form name="loginForm" method="post" action="judgeUser.jsp">

<table>

<tr>

<td>用戶名:<input type="text" name="userName" id="userName"></td>

</tr>

<tr>

<td>密碼:<input type="password" name="password" id="password"></td>

</tr>

<tr>

<td><input type="submit" value="登錄" style="background-color:pink"> <input

type="reset" value="重置" style="background-color:red"></td>

</tr>

</table>

</form>

</body>

</html>

Data_uil.java文件代碼:

import java.sql.*;

public class Data_uil

{

public Connection getConnection()

{

try{

Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");

}catch(ClassNotFoundException e)

{

e.printStackTrace();

}

String user="***";

String password="***";

String url="jdbc:sqlserver://127.0.0.1:1433;DatabaseName=***";

Connection con=null;

try{

con=DriverManager.getConnection(url,user,password);

}catch(SQLException e)

{

e.printStackTrace();

}

return con;

}

public String selectPassword(String username)

{

Connection connection=getConnection();

String sql="select *from login where username=?";

PreparedStatement preparedStatement=null;

ResultSet result=null;

String password=null;

try{

preparedStatement=connection.prepareStatement(sql);

preparedStatement.setString(1,username);


result=preparedStatement.executeQuery();//可執行的 查詢

if(result.next())

password=result.getString("password");


}catch(SQLException e){

e.printStackTrace();

}finally

{

close(preparedStatement);

close(result);

close(connection);

}

System.out.println("找到的資料庫密碼為:"+password);

return password;

}

public void close (Connection con)

{

try{

if(con!=null)

{

con.close();

}

}catch(SQLException e)

{

e.printStackTrace();

}

}

public void close (PreparedStatement preparedStatement)

{

try{

if(preparedStatement!=null)

{

preparedStatement.close();

}

}catch(SQLException e)

{

e.printStackTrace();

}

}

public void close(ResultSet resultSet)

{

try{

if(resultSet!=null)

{

resultSet.close();

}

}catch(SQLException e)

{

e.printStackTrace();

}

}

}

2. 沈陽北大青鳥分享JSP編程開發包含哪些常用的庫

隨著網路程序設計開發技術的發展,有關軟體程序設計的框架和程序庫的種類也在增加。
今天,沈陽沈陽IT培訓大家了解典型JSP編程開發中有哪些庫。
1、ReactJSReact.js(React)是一個JavaScript庫,它主要使用MVC的V(視圖)React構建UI。
React起源於架設Instagram網站,2013年5月開放源代碼化的Facebook內部項目。
沈陽java培訓發現React提供了高性能,代碼邏輯非常簡單,並且越來越多的人開始關注並使用它。
2、AngularJSAngularJS是一組框架、模板、數據綁定和豐富的UI組件,用於開發Web頁。
支持整個開發過程並提供Web應用程序架構,而無需手動DOM操作。
沈陽沈陽UI設計培訓發現AngularJS非常小,只有60K,與主流瀏覽器兼容,與jQuery相配。
3、Vue.jsVue.js是一個JavaScript庫,用於構建Web界面,提供數據驅動組件,並提供簡單靈活的API以簡化MVVM。
4、Angular2Angular是一個非常流行且易於使用的Web前端框架,現在由Google維護。
北大青鳥發現此條目包含Angular2及其後續版本。
因為Angular2和Angular.js的早期版本是單獨管理的(它們的GitHub地址和項目主頁不相同),所以它們都有此頁。

3. jsp 通過輸入一個條件 然後鏈接到資料庫 把資料庫中有這個條件的信息取

哎 我給你最簡單的例子
兩個簡單的jsp頁面,資料庫連接(我給你的是mysql資料庫連接示例,後面附sqlserver資料庫連接部分關鍵代碼)
首先是 獲取值頁面My.jsp 源碼:
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'My.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
<form action="Hp.jsp">
name:<input name="name" value="" type="text"></br>
password:<input name="password" value="" type="text"></br>
<input type="submit" value="button">
</form>
</body>
</html>
處理頁面 Hp.jsp 源碼:
<%@ page language="java" import="java.util.*,java.sql.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>My JSP 'Hp.jsp' starting page</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->

</head>

<body>
<%
Connection con = null;
Statement stm = null;

String url = "jdbc:mysql://localhost:3306/數據名稱";//資料庫名稱就是你的資料庫名字
String driver = "com.mysql.jdbc.Driver"; //驅動類位置
String username = "root"; //資料庫登錄名稱,此處寫上你的用戶名稱
String pwd = "root"; //資料庫登錄密碼,此處寫上你的登錄密碼
try
{
Class.forName(driver);
con = DriverManager.getConnection(url, username, pwd); //創建Connection連接對象
stm = con.createStatement(); //創建Statement 命令執行對象
}
catch (ClassNotFoundException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

String name=request.getParameter("name"); //獲取傳過來的名稱
String password=request.getParameter("password");//獲取傳過來的密碼

String sql="insert into user(name,password) values("+name+","+password+")";//資料庫添加一條記錄sql語句

int temp=stm.executeUpdate(sql);

if(temp>0)
{
out.print("添加成功");
}
else
{
out.print("添加失敗");
}
//關閉資料庫連接
stm.close();
con.close();

%>
</body>
</html>
注意 連接不同資料庫要導入不同的資料庫驅動包 你要導入才行啊
附 sqlserver資料庫連接 部分關鍵代碼:
private static Connection con = null;
private static Statement stm = null;

private static String url = "jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=資料庫名稱";
private static String driver = "com.microsoft.jdbc.sqlserver.SQLServerDriver";//與mysql有所不同
private static String username = "sa";//默認用戶
private static String pwd = "123"; //密碼

static {
try {
Class.forName(driver);

con = DriverManager.getConnection(url, username, pwd);
System.out.print("連接成功!");
stm = con.createStatement();
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}

4. 我從CSDN下載的JSP+MYSQL的源碼怎麼用

把你的項目導入MyEclipse中,然後把sql文件導入mysql中,生成本地的資料庫,接著找到項目中配置資料庫連接的java類,把資料庫的用戶名和密碼改成你自己的資料庫的用戶名和密碼(這步很重要),最後把項目部署到tomcat中,啟動tomcat伺服器,就可以運行了!祝你好運!

5. 河南北大青鳥:JSP編程開發包含哪些常用的庫

隨著網路程序設計開發技術的發展,有關軟體程序設計的框架和程序庫的種類也在增加。
今天,河南河南IT培訓大家了解典型JSP編程開發中有哪些庫。
1、ReactJSReact.js(React)是一個JavaScript庫,它主要使用MVC的V(視圖)React構建UI。
React起源於架設Instagram網站,2013年5月開放源代碼化的Facebook內部項目。
河南java培訓發現React提供了高性能,代碼邏輯非常簡單,並且越來越多的人開始關注並使用它。
2、AngularJSAngularJS是一組框架、模板、數據綁定和豐富的UI組件,用於開發Web頁。
支持整個開發過程並提供Web應用程序架構,而無需手動DOM操作。
河南河南UI設計培訓發現AngularJS非常小,只有60K,與主流瀏覽器兼容,與jQuery相配。
3、Vue.jsVue.js是一個JavaScript庫,用於構建Web界面,提供數據驅動組件,並提供簡單靈活的API以簡化MVVM。
4、Angular2Angular是一個非常流行且易於使用的Web前端框架,現在由Google維護。
北大青鳥發現此條目包含Angular2及其後續版本。
因為Angular2和Angular.js的早期版本是單獨管理的(它們的GitHub地址和項目主頁不相同),所以它們都有此頁。

6. 如何在JSP頁面顯示mysql資料庫內容

直接上個jsp顯示mysql資料庫內容的源碼,你可以參考一下:

<spanstyle="font-size:12px;"><spanstyle="font-size:14px;"><%@pagelanguage="java"import="java.sql.*,java.io.*,java.util.*"%>
<%@pagecontentType="text/html;charset=utf-8"%>
<html>
<head>
<styletype="text/css">
table{
border:2px#CCCCCCsolid;
width:360px;
}
td,th{
height:30px;
border:#CCCCCC1pxsolid;
}
</style>
</head>
<body>
<%
//驅動程序名
StringdriverName="com.mysql.jdbc.Driver";
//資料庫用戶名
StringuserName="root";
//密碼
StringuserPasswd="szy";
//資料庫名
StringdbName="studentmanage";
//表名
StringtableName="student";
//聯結字元串
Stringurl="jdbc:mysql://localhost:3306/"+dbName+"?user="
+userName+"&password="+userPasswd;
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connectionconnection=DriverManager.getConnection(url);
Statementstatement=connection.createStatement();
Stringsql="SELECT*FROM"+tableName;
ResultSetrs=statement.executeQuery(sql);
%>
<br>
<br>
<tablealign="center">
<tr>
<th>
<%
out.print("學號");
%>
</th>
<th>
<%
out.print("姓名");
%>
</th>
<th>
<%
out.print("專業");
%>
</th>
<th>
<%
out.print("班級");
%>
</th>
</tr>
<%
while(rs.next()){
%>
<tr>
<td>
<%
out.print(rs.getString(1));
%>
</td>
<td>
<%
out.print(rs.getString(2));
%>
</td>
<td>
<%
out.print(rs.getString(3));
%>
</td>
<td>
<%
out.print(rs.getString(4));
%>
</td>
</tr>
<%
}
%>
</table>
<divalign="center">
<br><br><br>
<%
out.print("數據查詢成功,恭喜你");
%>
</div>
<%
rs.close();
statement.close();
connection.close();
%>
</body>
</html></span><spanstyle="font-size:24px;color:rgb(255,0,0);">
</span></span>
熱點內容
內置存儲卡可以拆嗎 發布:2025-05-18 04:16:35 瀏覽:335
編譯原理課時設置 發布:2025-05-18 04:13:28 瀏覽:378
linux中進入ip地址伺服器 發布:2025-05-18 04:11:21 瀏覽:612
java用什麼軟體寫 發布:2025-05-18 03:56:19 瀏覽:32
linux配置vim編譯c 發布:2025-05-18 03:55:07 瀏覽:107
砸百鬼腳本 發布:2025-05-18 03:53:34 瀏覽:943
安卓手機如何拍視頻和蘋果一樣 發布:2025-05-18 03:40:47 瀏覽:739
為什麼安卓手機連不上蘋果7熱點 發布:2025-05-18 03:40:13 瀏覽:803
網卡訪問 發布:2025-05-18 03:35:04 瀏覽:511
接收和發送伺服器地址 發布:2025-05-18 03:33:48 瀏覽:371