ºìÁªLinuxÃÅ»§
Linux°ïÖú

JSP·ÃÎÊÊý¾Ý¿â´óÈ«

·¢²¼Ê±¼ä:2006-03-02 00:36:42À´Ô´:ºìÁª×÷Õß:Myiozzdoc
ÏÖÔÚÓкöà³õѧjspµÄÍøÓѾ­³£»áÎÊÊý¾Ý¿âÔõôÁ¬½Ó°¡£¬ÔõôÀϳö´í°¡£¿ËùÒÔÎÒ¼¯ÖеÄÔÚÕâдƪÎÄÕ¹©´ó¼Ò²Î¿¼£¬ÆäʵÕâÖÖ°ÑÊý¾Ý¿âÂß¼­È«²¿·ÅÔÚjspÀïδ±ØÊǺõÄ×ö·¨£¬µ«ÊÇÓÐÀûÓÚ³õѧÕßѧϰ£¬ËùÒÔÎÒ¾ÍÕâÑù×öÁË£¬µ±´ó¼Òѧµ½Ò»¶¨³Ì¶ÈµÄʱºò£¬¿ÉÒÔ¿¼ÂÇÓÃMVCµÄģʽ¿ª·¢¡£ÔÚÁ·Ï°ÕâЩ´úÂëµÄʱºò£¬ÄãÒ»¶¨½«jdbcµÄÇý¶¯³ÌÐò·Åµ½·þÎñÆ÷µÄÀà·¾¶ÀȻºóÒªÔÚÊý¾Ý¿âÀィһ¸ö±ítest,ÓÐÁ½¸ö×ֶαÈÈçΪtest1£¬test2£¬¿ÉÒÔÓÃÏÂÃæ SQL½¨ create table test(test1 varchar(20),test2 varchar(20)£¬È»ºóÏòÕâ¸ö±íдÈëÒ»Ìõ²âÊԼͼ£¬ÄÇôÏÖÔÚ¿ªÊ¼ÎÒÃǵÄjspºÍÊý¾Ý¿âÖ®Âðɡ£

¡¡¡¡Ò»¡¢jspÁ¬½ÓOracle8/8i/9iÊý¾Ý¿â£¨ÓÃthinģʽ£©
testoracle.jspÈçÏ£º
ÒýÓÃ:
£¼%@ page contentType="text/html;charset=gb2312"%£¾
£¼%@ page import="java.sql.*"%£¾
£¼html£¾
£¼body£¾
£¼%Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
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()) {%£¾
ÄúµÄµÚÒ»¸ö×Ö¶ÎÄÚÈÝΪ£º£¼%=rs.getString(1)%£¾
ÄúµÄµÚ¶þ¸ö×Ö¶ÎÄÚÈÝΪ£º£¼%=rs.getString(2)%£¾
£¼%}%£¾
£¼%out.print("Êý¾Ý¿â²Ù×÷³É¹¦£¬¹§Ï²Äã");%£¾
£¼%rs.close();
stmt.close();
conn.close();
%£¾
£¼/body£¾
£¼/html£¾


¡¡¡¡¶þ¡¢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Á¬½ÓDB2Êý¾Ý¿â
testdb2.jspÈçÏ£º
£¼%@ page contentType="text/html;charset=gb2312"%£¾
£¼%@ page import="java.sql.*"%£¾
£¼html£¾
£¼body£¾
£¼%Class.forName("com.ibm.db2.jdbc.app.DB2Driver ").newInstance();
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()) {%£¾
ÄúµÄµÚÒ»¸ö×Ö¶ÎÄÚÈÝΪ£º£¼%=rs.getString(1)%£¾
ÄúµÄµÚ¶þ¸ö×Ö¶ÎÄÚÈÝΪ£º£¼%=rs.getString(2)%£¾
£¼%}%£¾
£¼%out.print("Êý¾Ý¿â²Ù×÷³É¹¦£¬¹§Ï²Äã");%£¾
£¼%rs.close();
stmt.close();
conn.close();
%£¾
£¼/body£¾
£¼/html£¾

¡¡¡¡ËÄ¡¢jspÁ¬½ÓInformixÊý¾Ý¿â
testinformix.jspÈçÏ£º
ÒýÓÃ:
£¼%@ page contentType="text/html;charset=gb2312"%£¾
£¼%@ page import="java.sql.*"%£¾
£¼html£¾
£¼body£¾
£¼%Class.forName("com.informix.jdbc.IfxDriver").newInstance();
String url =
"jdbc:informix-sqli://123.45.67.89:1533/testDB:INFORMIXSERVER=myserver;
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()) {%£¾
ÄúµÄµÚÒ»¸ö×Ö¶ÎÄÚÈÝΪ£º£¼%=rs.getString(1)%£¾
ÄúµÄµÚ¶þ¸ö×Ö¶ÎÄÚÈÝΪ£º£¼%=rs.getString(2)%£¾
£¼%}%£¾
£¼%out.print("Êý¾Ý¿â²Ù×÷³É¹¦£¬¹§Ï²Äã");%£¾
£¼%rs.close();
stmt.close();
conn.close();
%£¾
£¼/body£¾
£¼/html£¾


¡¡¡¡Îå¡¢jspÁ¬½ÓAccessÊý¾Ý¿â
£¼%@page import="java.sql.*"
import ="java.util.*"
import ="java.io.*"
import="java.text.*"
contentType="text/html; charset=gb2312"
buffer="20kb"
%£¾£¼%! int all,i,m_count;
String odbcQuery;
Connection odbcconn;
Statement odbcstmt;
ResultSet odbcrs;
String username,title,content,work,email,url,time,date;
String datetime;
%£¾
£¼%
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}catch (ClassNotFoundException e)
{ out.print ("Çý¶¯³ÌÐò²»´æÔÚ");
}
try{
odbcconn = DriverManager.getConnection("jdbc:odbc:db1");
odbcstmt = odbcconn.createStatement();
odbcQuery="Select * From book where datetime£¾2001-4-26 Order By datetime DESC";
odbcrs=odbcstmt.executeQuery(odbcQuery);
int i=0;
while (i£¼130) odbcrs.next();
while (odbcrs.next())
{
//*/////////////////////////ÏÔʾÊý¾Ý¿âµÄÄÚÈÝÓÃÓÚµ÷ÊÔ³ÌÐòÊÇÓÃ//
int ii;
try{
try{
for (ii=1;;ii++)
out.print ("£¼br£¾Cloumn "+ii+" is: "+odbcrs.getString(ii));
}catch (NullPointerException e) {
out.print ("ÓпյÄÖ¸Õë");
}
}catch (SQLException e){
}
}
odbcrs.close();
odbcstmt.close();
odbcconn.close();
}catch (SQLException e)
{ out.print (e);
}
%£¾
ÎÄÕÂÆÀÂÛ

¹²ÓÐ 62 ÌõÆÀÂÛ

  1. 125.7.203.* ÓÚ 2007-08-07 18:14:18·¢±í:

    ucezo wvztrl mcvfptrlu yzkq khyqv tbxoqvjp xrqyfn

  2. 88.245.93.* ÓÚ 2007-07-17 16:02:10·¢±í:

    http://f231f66434db73b8064f3da22331a4c1-t.xkktxb.org f231f66434db73b8064f3da22331a4c1 http://f231f66434db73b8064f3da22331a4c1-b1.xkktxb.org f231f66434db73b8064f3da22331a4c1 http://f231f66434db73b8064f3da22331a4c1-b3.xkktxb.org 8d1f2bfe3cbc5359328d95464cab8b7c