一、jsp連線oracle8/8i/9i資料庫(用thin模式)
testoracle.jsp如下:
string url="jdbc:oracle:thin:@localhost:1521:orcl";
//orcl為你的資料庫的sid
string user="scott";
string password="tiger";
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()) {%>
您的第乙個字段內容為:
您的第二個字段內容為:
stmt.close();
conn.close();
二、jsp連線sql server7.0/2000資料庫
testsqlserver.jsp如下:
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()) {%>
您的第乙個字段內容為:
您的第二個字段內容為:
stmt.close();
conn.close();
三、jsp連線db2資料庫
testdb2.jsp如下:
string url="jdbc:db2://localhost:5000/sample";
//sample為你的資料庫名
string user="admin";
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()) {%>
您的第乙個字段內容為:
您的第二個字段內容為:
stmt.close();
conn.close();
四、jsp連線informix資料庫
testinformix.jsp如下:
string url =
"jdbc:informix-sqli:
user=testuser;password=testpassword";
//testdb為你的資料庫名
connection conn= drivermanager.getconnection(url);
statement stmt=conn.createstatement(resultset.type_scroll_sensitive,resultset.concur_updatable);
string sql="select * from test";
resultset rs=stmt.executequery(sql);
while(rs.next()) {%>
您的第乙個字段內容為:
您的第二個字段內容為:
stmt.close();
conn.close();
五、jsp連線sybase資料庫
testmysql.jsp如下:
string url =" jdbc:sybase:tds:localhost:5007/tsdata";
//tsdata為你的資料庫名
properties sysprops = system.getproperties();
sysprops.put("user","userid");
sysprops.put("password","user_password");
connection conn= drivermanager.getconnection(url, sysprops);
statement stmt=conn.createstatement(resultset.type_scroll_sensitive,resultset.concur_updatable);
string sql="select * from test";
resultset rs=stmt.executequery(sql);
while(rs.next()) {%>
您的第乙個字段內容為:
您的第二個字段內容為:
stmt.close();
conn.close();
六、jsp連線mysql資料庫
testmysql.jsp如下:
string url ="jdbc:mysql://localhost/softforum?user=soft&password=soft1234&useunicode=true&characterencoding=8859_1"
//testdb為你的資料庫名
connection conn= drivermanager.getconnection(url);
statement stmt=conn.createstatement(resultset.type_scroll_sensitive,resultset.concur_updatable);
string sql="select * from test";
resultset rs=stmt.executequery(sql);
while(rs.next()) {%>
您的第乙個字段內容為:
您的第二個字段內容為:
stmt.close();
conn.close();
七、jsp連線postgresql資料庫
testmysql.jsp如下:
string url ="jdbc:postgresql://localhost/soft"
//soft為你的資料庫名
string user="myuser";
string password="mypassword";
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()) {%>www.2cto.com
您的第乙個字段內容為:
您的第二個字段內容為:
stmt.close();
conn.close();
jsp連線資料庫大全
create table test test1 varchar 20 test2 varchar 20 一 jsp連線oracle8 8i 9i資料庫 用thin模式 orcl為你的資料庫的sid pubs為你的資料庫的 三 jsp連線db2資料庫 sample為你的資料庫名 testdb為你的資料...
JSP連線資料庫大全
一 jsp連線oracle8 8i 9i資料庫 用thin模式 testoracle.jsp如下 class.forname oracle.jdbc.driver.oracledriver newinstance string url jdbc oracle thin localhost 1521 ...
jsp連線資料庫大全
現在有好多初學jsp sun企業級應用的首選 的經常會問資料庫怎麼連線啊,怎麼老出錯啊?所以我集中的在這寫篇文章供大家參考,其實這種把資料庫邏輯全部放在jsp sun企業級應用的首選 裡未必是好的做法,但是有利於初學者學習,所以我就這樣做了,當大家學到一定程度的時候,可以考慮用mvc的模式開發。在練...