MS SQL Server2000 ÔÚtomcatϵÄÊý¾ÝÔ´ÅäÖÃ
MS SQL Server2000 Êý¾ÝÔ´ÅäÖÃ
£¨×¢£ºsqljdbc.jarÏÂÔØ²»µ½µÄ»°£¬ÕÒÎÒË÷È¡pengqinghui110@126.com)
1¡¢ÔÚÏîÄ¿µÄWebRootϵÄMETA-INFÖÐн¨context.xmlÎļþ¡£ÄÚÈÝÈçÏ£º
<?xml version="1.0" encoding="UTF-8"?>
<Context>
<Resource name="jdbc/sqlserver"
auth="Container"
type="javax.sql.DataSource"
driverClassName="com.microsoft.sqlserver.jdbc.SQLServerDriver"
url="jdbc:sqlserver://localhost:1433"
username="sa"
password="123456"
maxActive="20"
maxIdle="10"
maxWait="-1" />
</Context>
2¡¢ÍùÏîĿϵÄweb.xmlÖÐÐÂÔöÈçÏ´úÂ룺
<resource-ref>
<res-ref-name>jdbc/sqlserver</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
3¡¢°Ñsqljdbc.jar·Åµ½tomcatµÄlibĿ¼ÏÂ
4¡¢±àд²âÊÔ³ÌÐòÈçÏÂ
<%@ page language="java" import="javax.naming.*,javax.sql.*,java.sql.*" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Êý¾ÝÔ´²âÊÔ</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"
Ïà¹ØÎĵµ£º
Ó¦Ò»¸öÅóÓѵÄÒªÇó£¬ÌùÉÏÊղصÄSQL³£Ó÷ÖÒ³µÄ°ì·¨¡«¡«
±íÖÐÖ÷¼ü±ØÐëΪ±êʶÁУ¬[ID] int IDENTITY (1,1)
1.·ÖÒ³·½°¸Ò»£º(ÀûÓÃNot InºÍSELECT TOP·ÖÒ³)
Óï¾äÐÎʽ£º
SELECT TOP Ò³¼Ç¼ÊýÁ¿ *
from ±íÃû
WHERE (ID NOT IN
(SELECT TOP (ÿҳÐÐÊý*(Ò³Êý-1)) ID
from ±íÃû
ORDER BY ......
Ò»£ºSelectÓï¾ä£º
select ×Ö¶ÎÃû from ±íÃû where Ìõ¼þ order by ÅÅÐò
see:select distinct ´Ó¶à¸öÏàͬ×Ö¶ÎÖÐץΨһֵ
see:²éÕÒld_det_andy±íÖÐÓÐÊý¾Ýµ«ld_det_temp±íÖÐûÊý¾ÝµÄÊý¾Ý
select * from ld_det_a ......
DB2 SQL PL
SQL PLÊÇDB2ËùÖ§³ÖµÄ¹ý³Ì»¯ÓïÑÔ£¬ËüÊÇSQL/PSM±ê×¼µÄÒ»¸ö×Ó¼¯¡£Æä¸ù¾ÝÓ¦Ó÷¶Î§²»Í¬£¬ÓÖ·ÖΪInline SQL PL£¬Embeded SQL PLºÍCompiled SQL PL¡£
Inline SQL PL
ÊÊÓ÷¶Î§£º´¥·¢Æ÷¡¢º¯ÊýºÍ·½·¨£¬Ö§³Ö²¿·ÖSQL PL£¬Ê¹ÓÃʱҪעÒâһЩÏÞÖÆ
Óï·¨¹æÔò£ºBEGIN ATOMIC ... END
Embeded SQL PL
ÊÊÓ÷¶Î§£ºÇ¶Èëʽ£¬Åäº ......
1¡¢ÔÚÊý¾Ý¿â½¨±íµÄʱºò×Ö¶ÎÖ±½ÓÉèÖÃΪDATETIMEÀàÐÍ£»
2¡¢Ö´ÐвåÈëµÄʱºòʹÓÃÈçÏÂÓï¾ä£º
PreparedStatement pstmt = conn.prepareStatement("insert into guestbook(gst_user,gst_title,gst_content,gst_ip,gst_time) values(?,?,?,?,getdate())");
3¡¢Òª°ÑÈÕÆÚ´ÓÊý¾Ý¿âÖÐÈ¡³ö£¬Ö´ÐÐÈçÏÂÓï¾ä£º
......