JDBCµ÷ÓÃSql server 2005 ´æ´¢¹ý³Ì³öÏÖµÄÎÊÌâ
»·¾³£ºJDK1.5
Êý¾Ý¿â£ºSql server 2005 +sp2
JDBCÇý¶¯£ºsqljdbc.jar
²âÊÔÀà´úÂëÈçÏ£º
import java.sql.*;
public class test {
/**
* @param args
* @throws SQLException
* @throws ClassNotFoundException
*/
public static void main(String[] args) throws SQLException, ClassNotFoundException {
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
Connection con = DriverManager.getConnection("jdbc:sqlserver://192.168.1.168:1433;SelectMethod=cursor;DatabaseName=DBName", "sa", "sa");
//PreparedStatement ps = con.prepareCall("exec Proc_checkPDDateTime '00','00'"); --ʹÓÃPreparedStatementÒ²¿ÉÒÔ
CallableStatement ps = con.prepareCall("{call dbo.Proc_checkPDDateTime('1602327','20100526162514')}");
//{µÚÒ»ÖÖ·½Ê½} Á½ÖÖ·½Ê½µ÷Óô洢¹ý³ÌµÄ·µ»ØÖµ¶¼¿ÉÒÔ
// ResultSet rs= ps.executeQuery();
// if(rs.next()){
// System.out.println("--"+rs.getString(1)+"--");
// }
//{µÚ¶þÖÖ·½Ê½}
if(ps.execute()){ --Èç¹ûpsÖ´Ðк󷵻صÄÊÇResultSet,ÄÇôps.execute·µ»ØTrue ,ÇÒ±ØÐëҪͨ¹ýps.getResultSet()·½·¨»ñµÃ½á¹û¼¯
if(ps.getResultSet().next()){
System.out.println("--"+ps.getResultSet().getString(1)+"--");
}
}
}
}
ÔËÐÐʱ£¬ÌáʾÈçÏ´íÎó£º
Exception in thread "main" com.microsoft.sqlserver.jdbc.SQLServerException: ÎÞ·¨ÔÚ¸ø¶¨µÄÓï¾äÖдò¿ª·þÎñÆ÷ÓαꡣÇëʹÓÃĬÈϽá¹û¼¯»ò¿Í»§¶ËÓαꡣ
at com.microsoft.sqlserver.jdbc.SQLServerException.makefromDatabaseError(Unknown Source)
at com.microsoft.sqlserver.jdbc.IOBuffer.processPackets(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.sendExecute(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.doExecute(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerPrepa
Ïà¹ØÎĵµ£º
±¾ÎÄÕÂÔ´´ÓÚwww.yafeilinux.com תÔØÇë×¢Ã÷³ö´¦¡£
SQL¼´½á¹¹»¯²éѯÓïÑÔ£¬ÊǹØϵÊý¾Ý¿âµÄ±ê×¼ÓïÑÔ¡£Ç°ÃæÒѾÌáµ½£¬ÔÚQtÖÐÀûÓÃQSqlQueryÀàʵÏÖÁËÖ´ÐÐSQLÓï¾ä¡£ÐèҪ˵Ã÷£¬ÎÒÃÇÕâÀïÖ»ÊÇQt½Ì³Ì£¬¶ø·ÇרҵµÄÊý¾Ý¿â½Ì³Ì£¬ËùÒÔÎÒÃDz»»á¶ÔÊý¾Ý¿âÖеÄһЩ֪ʶ½øÐÐÉîÈë½²½â£¬ÏÂÃæÖ»ÊǶÔ×î³£Óõļ¸¸ö֪ʶµã½øÐн²½â¡£
ÎÒÃÇÏÂÃ ......
±¾ÎÄÕÂÔ´´ÓÚwww.yafeilinux.com תÔØÇë×¢Ã÷³ö´¦¡£
½Ó×ÅÉÏһƪ½Ì³Ì¡£
¶þ£¬ÔÚSQLÓï¾äÖÐʹÓñäÁ¿¡£
ÎÒÃÇÏÈ¿´ÏÂÃæµÄÒ»¸öÀý×Ó£¬½«“²éѯ”°´Å¥µÄ²Ûº¯Êý¸ü¸ÄÈçÏ£º
void Widget::on_pushButton_clicked()
{
QSqlQuery query;
query.prepare(“insert i ......
Á¬½Ó²éѯ£¬¾ÍÊǽ«
Á½¸ö»ò¶à¸ö
±í»òÊÓͼ
ͨ¹ýÒ»¶¨µÄÌõ¼þ
½«È«²¿»ò²¿·Ý×Ö¶Î
È«²¿»ò²¿·Ý¼Ç¼
Á¬½Óµ½Ò»Æ𣬵õ½Ò»¸öеÄÊý¾Ý¼¯ºÏ¡£
È磺ÓÐÈËÔ±µµ°¸ºÍ¹¤×ʵµ°¸Á½¸ö±í£¬Á½¸ö±íÓй²Í¬µÄ¹Ø¼ü×Ö¶ÎXMDM(ÐÕÃû´úÂ룩£¬ÆäÖÐÈËÔ±µµ°¸´æ´¢ÁËÈËÊÂ×ÊÁÏ£¬¹¤×ʵµ°¸´æ´¢ÁËн³ê×ÊÁÏ¡£
Òò´Ë¿ÉÒÔͨ¹ýXMDM×ֶν«Á½¸ö±íÁ¬½ÓÆðÀ´£¬´Ó¶øʹ²éѯ½ ......
Ò»¡¢·Öҳд·¨Ð¡Àý£º
SELECT FIRST 10 templateid,code,name from template ;
SELECT FIRST 10 SKIP 10 templateid,code,name from template ;
SELECT * from shop ROWS 1 TO 10; –firebird2.0Ö§³ÖÕâÖÖд·¨
¶þ¡¢ÏÔʾ±íÃûºÍ±í½á¹¹
SHOW TABLES;
SHOW TABLE tablename;
ËÄ¡¢¸üÐÂ×Ö¶Î×¢ÊÍ
......