Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

ÈçºÎÁ¬½ÓSQL ServerÊý¾Ý¿â£¨Java°æ£©

ÓÃJavaÁ¬½ÓSQL Server2000Êý¾Ý¿âÓжàÖÖ·½·¨£¬ÏÂÃæ½éÉÜÆäÖÐ×î³£ÓõÄÁ½ÖÖ£¨Í¨¹ýJDBCÇý¶¯Á¬½ÓÊý¾Ý¿â£©¡£
1. ͨ¹ýMicrosoftµÄJDBCÇý¶¯Á¬½Ó¡£´ËJDBCÇý¶¯¹²ÓÐÈý¸öÎļþ£¬·Ö±ðÊÇmssqlserver.jar¡¢msutil.jarºÍmsbase.jar£¬¿ÉÒÔµ½Î¢ÈíµÄÍøվȥÏÂÔØ£¨http://www.microsoft.com/downloads/details.aspx?FamilyId=07287B11-0502-461A-B138-2AA54BFDC03A&displaylang=en£©£¬Èç¹ûÄãÏÂÔصÄÊÇsetup.exe£¬»¹ÐèÒª°²×°Ëü£¬°²×°ºó»áÉú³ÉÉÏÃæµÄÈý¸öjarÎļþ¡£´ËJDBCÇý¶¯ÊµÏÖÁË JDBC 2.0¡£
Çý¶¯³ÌÐòÃû³Æ£ºcom.microsoft.jdbc.sqlserver.SQLServerDriver£¨¼´ÏÂÃæµÄclassforname£©
Êý¾Ý¿âÁ¬½ÓURL£ºjdbc:microsoft:sqlserver://localhost:1433;DatabaseName=dbname£¨¼´ÏÂÃæµÄurl£©
2. ͨ¹ýJTDS JDBC DriverÁ¬½ÓSQL ServerÊý¾Ý¿â£¬´ËÇý¶¯µÄÎļþÃûΪjtds-1.2.jar£¬ÏÂÔØ·¾¶Îª£¨http://sourceforge.net/project/showfiles.php?group_id=33291£©£¬´ËÇý¶¯Ö§³ÖMicrosoft SQL Server (6.5, 7.0, 2000 ºÍ2005) ºÍSybase£¬²¢ÇÒʵÏÖÁËJDBC3.0£¬ÊÇÃâ·ÑµÄ¡£
Çý¶¯³ÌÐòÃû³Æ£ºnet.sourceforge.jtds.jdbc.Driver£¨¼´ÏÂÃæµÄclassforname£©
Êý¾Ý¿âÁ¬½ÓURL£ºjdbc:jtds:sqlserver://localhost:1433/dbname£¨¼´ÏÂÃæµÄurl£©
JDBCÁ¬½ÓSQL ServerÊý¾Ý¿âµÄBean´úÂëÍøÉÏ´ó°ÑµÄÓУ¬ÏÂÃæժ¼ÆäÖеÄÒ»²¿·Ö£º£¨Ç뽫localhostºÍ1433¸Ä³ÉÄãʵ¼ÊÓ¦ÓÃÖеÄSQL Server·þÎñÆ÷µØÖ·ºÍ¶Ë¿ÚºÅ£¬dbname¸Ä³ÉÄãʵ¼ÊµÄÊý¾Ý¿âÃû£©
import java.sql.*;
public class DatabaseConn {
 private Connection conn;
 private Statement stmt;
 private String url = "jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=dbname";
 private String classforname = "com.microsoft.jdbc.sqlserver.SQLServerDriver";
 private String uid = "sa";
 private String pwd = "password";
 
 public DatabaseConn(){}
 
 /**
  * <p>ͨ¹ýMicrosoft JDBCÇý¶¯»ñµÃÊý¾Ý¿âÁ¬½Ó</p>
  * @return Connection
  * @exception ClassNotFoundException, SQLException
  */
 public Connection getConnection()
 {
  try
  {
   Class.forName(classforname);
   if (conn == null || conn.isClosed())
    conn = DriverMana


Ïà¹ØÎĵµ£º

³£ÓõÄSQLÓï¾ä

н¨±í£º
create table [±íÃû]
(
[×Ô¶¯±àºÅ×Ö¶Î] int IDENTITY (1,1) PRIMARY KEY ,
[×Ö¶Î1] nVarChar(50) default 'ĬÈÏÖµ' null ,
[×Ö¶Î2] ntext null ,
[×Ö¶Î3] datetime,
[×Ö¶Î4] money null ,
[×Ö¶Î5] int default 0,
[×Ö¶Î6] Decimal (12,4) default 0,
[×Ö¶Î7] image null ,
)
ɾ³ý±í£º
Drop table [±í ......

SQL²éѯÖеÄתÒå×Ö·û ÀÁèÐÇ¿Õ

Èç¹ûÏë²éÕÒ“_cs”½áβµÄµÄÕË»§
select * from [user] where loginname like '%_cs'ÊDz»Ðеģ¬_ ±»ÈÏΪÊÇÈÎÒâµÄ×Ö·û£¬
ËùÒÔÐèҪתÒå×Ö·û£¬ÓÐÁ½ÖÖд·¨£º
select * from [user] where loginname like '%[_]cs'
select * from [user] where loginname like '%/_cs' escape'/'
ͨÅä·ûº¬Òå
%
°üº¬Áã¸ö»ò¸ü¶à×Ö· ......

Top 10 Features of SQL 2008 R2

Introduction
Microsoft SQL Server 2008 R2 is the latest release of SQL Server. This article will introduce the top 10 features and benefits of SQL Server 2008 R2. The “R2” tag indicates this is an intermediate release of SQL Server and not a major revision. However, there are a number o ......

¡¾Ñ§Ï°É¢¼Ç7 SQLÓï¾äµÄ´¦Àí¡¿

SQLÓï¾äµÄ´¦Àí
ps£ºMSDNÕª
ÓÅ»¯ ÔÚ»ù´¡±íÉÏ£¨²»ÒýÓÃÊÓͼ»òÔ¶³Ì±í£©µÄ SELECT Óï¾ä:SELECT Óï¾äÊǷdzÌÐòÐÔµÄ,ÕâÒâζ×ÅÊý¾Ý¿â·þÎñÆ÷±ØÐë·ÖÎöÓï¾ä£¬ÒÔ¾ö¶¨ÌáÈ¡ËùÇëÇóÊý¾ÝµÄ×îÓÐЧ·½·¨
´¦ÀíÉÏÃæ²½ÖèµÄ×é¼þ³ÆΪ“²éѯÓÅ»¯Æ÷”£º
   ÊäÈ룺²éѯ¡¢Êý¾Ý¿â·½°¸£¨±íºÍË÷ÒýµÄ¶¨Ò壩ÒÔ¼°Êý¾Ý¿âͳ¼ÆÐÅÏ¢
& ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ