導航:首頁 > 編程大全 > jsp網頁連接資料庫

jsp網頁連接資料庫

發布時間:2021-04-01 07:11:46

A. 怎麼用jsp連接資料庫到網頁十萬火急

這是連接access資料庫的:
<%@ page import="java.sql.*"%>
<%
String strurl="jdbc:odbc:driver={Microsoft Access Driver (*.mdb)};DBQ=D:/jsp/tushu/inc/db.mdb";
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection conn= DriverManager.getConnection(strurl);
Statement stmt=conn.createStatement();
%>
這是連接sql2000資料庫的:
<sql:setDataSource var="conn"
driver="com.microsoft.jdbc.sqlserver.SQLServerDriver" url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=資料庫名稱" user="sa" password=""/>

運行jsp文件前先安裝這個軟體j2sdk-1_4_2_07-windows-i586-p.exe不然運行不了。

設置j2sdk環境:

變數名:java_home
變數值:D:\java\j2sdk1.4.2_07

變數名:classpath
變數值:.;%java_home%\lib

變數名:path
變數值:%java_home%\bin;

軟體:
JBuilder、eclipse、也可以用 Dreamweaver 8
有交流QQ說吧26158885

B. 如何用一張JSP頁面連接資料庫,實現查詢,修改操作

1.通過jdbc連接上資料庫,並從中獲取一個連接。(建議由一個工具類提供)
2.創建一個jsp頁面、一個servlet類和一個service業務邏輯類。
3.當點擊查詢按鈕時調用servlet並把文本框中的參數傳遞過去。
4.在servlet中獲取頁面傳遞過來的參數,並調用service中方法(此方法負責條件查詢並返回list集合)
5.servlet中把查詢集合放到request作用域並轉發到jsp頁面進行迭代,把數據取出展示即可。

C. JSP網站連接mysql資料庫

你的首頁打開的時候,沒有連資料庫嗎?
肯定有吧.
如果首頁沒有問題,那就說明連資料庫沒有問題啊..
500 是伺服器問題.

在用session的時候,如果異常了或者是用完了,注意一定要關閉..
你再試試吧.應該不會是資料庫的連接問題.

D. java 中 怎樣將JSP頁面與資料庫進行連接

這需要servlet作為中間環節,由servlet完成jsp頁面數據和資料庫數據的處理,然後再進行頁面轉向等操作

E. jsp頁面怎麼和資料庫連接

Str310

F. jsp動態網頁怎麼連接mysql資料庫

我感覺,最好不使用jsp去連接資料庫
<%@ page contentType="text/html; charset=gb2312" %>

<%@ page language="java" %>

<%@ page import="com.mysql.jdbc.Driver" %>

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

<%

//驅動程序

String driverName="com.mysql.jdbc.Driver";

//資料庫用戶名

String userName="cl41";

//密碼

String userPasswd="123456";

//資料庫名

String dbName="db";

//表名

String tableName="dbtest";

//聯結字元串

String url="jdbc:mysql://localhost/"+dbName+"?user="+userName+"&password="+userPasswd;

Class.forName("com.mysql.jdbc.Driver").newInstance();

Connection connection=DriverManager.getConnection(url);

Statement statement = connection.createStatement();

String sql="SELECT * FROM "+tableName;

ResultSet rs = statement.executeQuery(sql);

//獲得數據結果集合

ResultSetMetaData rmeta = rs.getMetaData();

//確定數據集的列數,亦欄位數

int numColumns=rmeta.getColumnCount();

// 輸出每一個數據值

out.print("id");

out.print("|");

out.print("num");

out.print("<br>");

while(rs.next()) {

out.print(rs.getString(1)+" ");

out.print("|");

out.print(rs.getString(2));

out.print("<br>");

}

out.print("<br>");

out.print("資料庫操作成功,恭喜你");

rs.close();

statement.close();

connection.close();

%>

G. html網頁怎麼通過jsp連接mysql資料庫,並且讀取資料庫中得數據,和寫入數據

1、導入.sql文件命令:mysql>
use
資料庫名;mysql>
source
d:/mysql.sql;
2、建立資料庫:版mysql>
create
database
庫名;
3、建立數據表:mysql>
use
庫名;mysql>
create
table
表名
(欄位名
varchar(20),
欄位名
char(1));
4、刪除數權據庫:mysql>
drop
database
庫名;
5、刪除數據表:mysql>
drop
table
表名;
6、將表中記錄清空:mysql>
delete
from
表名;
7、往表中插入記錄:mysql>
insert
into
表名
values
("hyq","m");
8、更新表中數據:mysql->
update
表名
set
欄位名1='a',欄位名2='b'
where
欄位名3='c';
9、用文本方式將數據裝入數據表中:mysql>
load
data
local
infile
"d:/mysql.txt"
into
table
表名;

H. 怎麼連接資料庫和JSP動態網頁

這個問題問的太寬泛

jdbc, hibernate都可以啊 hibernate也是封裝了jdbc的 用起來更方便點

隨便貼個jdbc連接SQL的例子吧

JSP連接SQL Server7.0/2000資料庫
testsqlserver.jsp如下:
<%@ page contentType="text/html;charset=gb2312"%>
<%@ page import="Java.sql.*"%>
<html>
<body>
<%Class.forName("com.microsoft.JDBC.sqlserver.SQLServerDriver").newInstance();
String url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=pubs";
//pubs為你的資料庫的
String user="sa";
String password="";

Connection conn= DriverManager.getConnection(url,user,password);
Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
String sql="select * from test";
ResultSet rs=stmt.executeQuery(sql);
while(rs.next()) {%>
您的第一個欄位內容為:<%=rs.getString(1)%>
您的第二個欄位內容為:<%=rs.getString(2)%>
<%}%>
<%out.print("資料庫操作成功,恭喜你");%>
<%rs.close();
stmt.close();
conn.close();

%>
</body>
</html>

閱讀全文

與jsp網頁連接資料庫相關的資料

熱點內容
ug找不到指定的許可文件 瀏覽:850
數控編程g01表示什麼 瀏覽:700
java實用類 瀏覽:190
去年做哪個網站能致富 瀏覽:727
多少的cad版本能打開pdf格式文件 瀏覽:540
win10文件比率是什麼 瀏覽:652
msdb資料庫置疑 瀏覽:210
移動花卡免流app為什麼要10元 瀏覽:147
xamppphp配置文件 瀏覽:268
刪除ghost文件 瀏覽:642
蘋果7可置換地方 瀏覽:763
win10騰訊文件夾在哪裡 瀏覽:262
在網站前面加什麼可以看會員視頻 瀏覽:908
哪個讀書app支持格式最全 瀏覽:322
魅族mx3提示網路可能會受到監控 瀏覽:308
如何判斷復制文件是否完整 瀏覽:803
qq接收的語音文件在 瀏覽:408
手機qq禁止查看動態 瀏覽:923
如何用編程求解二重積分 瀏覽:366
在桌面上搜索不到文件夾 瀏覽:723

友情鏈接