導航:首頁 > 編程大全 > 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網頁連接資料庫相關的資料

熱點內容
打電話時不能使用網路是什麼原因 瀏覽:919
ps怎麼將文件合並 瀏覽:747
java的日期格式化 瀏覽:981
電腦應用程序怎麼關 瀏覽:986
微信上鏈接在哪個文件夾 瀏覽:691
歐姆龍安裝打開找不到密鑰文件 瀏覽:302
蘋果基本表情 瀏覽:128
我的世界教育版編程在哪裡 瀏覽:842
pong文件夾找不到 瀏覽:759
69版本黑切 瀏覽:997
杭州道富java 瀏覽:635
知道qq號查微博賬號和密碼 瀏覽:294
紅手指自帶哪些app 瀏覽:103
手機用公司網路會被監控哪些 瀏覽:409
什麼叫py編程 瀏覽:370
微信紅包尾數作弊器ios 瀏覽:280
ipad備份文件夾 瀏覽:555
vivo手機qq下載的文件在哪裡 瀏覽:303
如何導出ug的編程檔 瀏覽:343
編程課如何提到游戲 瀏覽:430

友情鏈接