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();
}
相关文档:
SQL与过程化程序设计语言
SQL是一种典型的非过程化程序设计语言,这种语言的特点是:
只指定哪些数据被操纵,至于对这些数据要执行哪些操作,以及这
些操作是如何
执行的 ......
前提,MS SQL的通配符含义:
序号
通配符
含义
示例
1
%
包含零个或多个字符的任意字符串。
WHERE title LIKE '%computer%' 将查找在书名中任意位置包含单词"computer" 的所有书名。
2
_
任何单个字符。
WHERE au_fname LIKE '_ean' 将查找以 ean 结尾的所有 4 个字母的名字(Dean、Sean 等)。
3
[ ] ......