SQL Server JDBC Deriver Problems
If the SQL data type is 'timestamp', we need to use ResultSet.getBytes() to retrieve its value. If the SQL data type is 'datetime', we can use ResultSet.getTimestamp(). It is said timestamp is interanlly saved as binary data.
try {
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
Connection conn = DriverManager.getConnection
("jdbc:sqlserver://<url_address>;user=<user>;password=<password>;database=<database>");
Statement statement = conn.createStatement
(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
ResultSet rs = statement.executeQuery("...");
while (rs.next()) {
System.out.println(rs.getTimestamp(1));
}
} catch (Exception e) {
e.printStackTrace();
}
Ïà¹ØÎĵµ£º
ÔÒò·ÖÎö:
SERVERPROPERTY º¯ÊýµÄ ServerName ÊôÐÔÓë@@SERVERNAME ·µ»ØÏàËÆµÄÐÅÏ¢¡£ServerName ÊôÐÔÌṩWindows ·þÎñÆ÷ºÍʵÀýÃû³Æ£¬Á½Õß¹²Í¬¹¹³ÉΨһµÄ·þÎñÆ÷ʵÀý£»@@SERVERNAME Ìṩµ±Ç°ÅäÖõı¾µØ·þÎñÆ÷Ãû³Æ¡£
Èç¹û°²×°Ê±Î´¸ü¸ÄĬÈÏ·þÎñÆ÷Ãû³Æ£¬Ôò ServerName ÊôÐÔºÍ @@SERVERNAME ·µ»ØÏàͬµÄÐÅÏ¢¡£Èç¹ûÔÚ°²×°Ê±Òѽ«±¾µ ......
ǰÌá,MS SQLµÄͨÅä·ûº¬Ò壺
ÐòºÅ
ͨÅä·û
º¬Òå
ʾÀý
1
%
°üº¬Áã¸ö»ò¶à¸ö×Ö·ûµÄÈÎÒâ×Ö·û´®¡£
WHERE title LIKE '%computer%' ½«²éÕÒÔÚÊéÃûÖÐÈÎÒâλÖðüº¬µ¥´Ê"computer" µÄËùÓÐÊéÃû¡£
2
_
Èκε¥¸ö×Ö·û¡£
WHERE au_fname LIKE '_ean' ½«²éÕÒÒÔ ean ½áβµÄËùÓÐ 4 ¸ö×ÖĸµÄÃû×Ö£¨Dean¡¢Sean µÈ£©¡£
3
[ ] ......
ÊÇÓÃÓÚ·ÃÎʺʹ¦ÀíÊý¾Ý¿âµÄ±ê×¼µÄ¼ÆËã»úÓïÑÔ¡£
ͨ¹ý SQL À´¹ÜÀíÊý¾Ý
½á¹¹»¯²éѯÓïÑÔ (SQL) ÊÇÓÃÓÚ·ÃÎÊÊý¾Ý¿âµÄ±ê×¼ÓïÑÔ£¬ÕâЩÊý¾Ý¿â°üÀ¨ SQL Server¡¢Oracle¡¢MySQL¡¢Sybase ÒÔ¼° Access µÈµÈ¡£
¶ÔÓÚÄÇЩϣÍûÔÚÊý¾Ý¿âÖд洢Êý¾Ý²¢´ÓÖлñÈ¡Êý¾ÝµÄÈËÀ´Ëµ£¬SQL µÄ֪ʶÊǼÛÖµÎÞ·¨ºâÁ¿µÄ¡£
ʲôÊÇ SQL?
SQL Ö¸½á¹¹»¯²éѯÓïÑÔ ......
ÏÂÁÐÓï¾ä²¿·ÖÊÇMssqlÓï¾ä£¬²»¿ÉÒÔÔÚaccessÖÐʹÓá£
¡¡¡¡SQL·ÖÀࣺ
¡¡¡¡DDL—Êý¾Ý¶¨ÒåÓïÑÔ
(CREATE£¬ALTER£¬DROP£¬DECLARE)
¡¡¡¡DML—Êý¾Ý²Ù×ÝÓïÑÔ
(SELECT£¬DELETE£¬UPDATE£¬INSERT)
¡¡¡¡DCL—Êý¾Ý¿ØÖÆÓïÑÔ
(GRANT£¬REVOKE£¬COMMIT£¬ROLLBACK)
¡¡¡¡Ê×ÏÈ,¼òÒª½éÉÜ»ù´¡Óï¾ä£º
¡¡¡¡1¡¢ËµÃ÷£º´´½¨Êý ......
ÔÚAsp.netºóÓкܶೣÓõıí½á¹¹ membership¾ÍÊÇÒ»¸öµäÐÍ£¬³ý´Ë»¹ÓÐcode±í
CREATE TABLE [dbo].[CodeTables](
[CodeTableID] [uniqueidentifier] NOT NULL,
[ParentCodeTableID] [uniqueidentifier] NULL,
[Name] [varchar](200) COLLATE SQL_Latin1_General_ ......