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

sql server2005 jdbc½â¾ö×Ô¶¯Ôö³¤ÁÐͳһ´¦ÀíÎÊÌâ

±³¾°£ºÏµÍ³ÒªÖ§³Ö¶àÖÖÊý¾Ý¿â£¬Í³Ò»insertµÄʱºò»ñÈ¡×Ô¶¯Ôö³¤ÁеĴ¦Àí·½Ê½
ÎÊÌâ1£ºinsert select·½°¸
sqlserver2000Äܹ»Ê¹ÓÃinsertSql SELECT @@IDENTITY AS 'Identity'µÄ·½Ê½À´»ñµÃ£¬µ«ÊÇmysqlÔòÖ»ÄÜʹÓÃexecuteUpdate(insertSql);
executeQuery('SELECT last_insert_id() ')ÕâÑùµÄ·½Ê½£¬·ñÔò»áÅ׳öÒì³££ºjava.sql.SQLException: Can not issue data manipulation statements with executeQuery()
¶øÁ½¾ä»°·Ö¿ª´¦Àí£¬×ÜÈÃÈ˸оõ²»·ÅÐÄ£¬¼ÙÈç²¢·¢²Ù×÷±È½Ï¶à£¬´æÔÚDZÔÚµÄΣÏÕ¡£
ÎÊÌâ2£ºgetGeneratedKeys·½°¸
mysqlµÄÇý¶¯Ö§³Öjdbc3.0,ʵÏÖÁËgetGeneratedKeys()£¬µ«sqlserver2000 jdbcÇý¶¯²»Ö§³ÖgetGeneratedKeys()
½â¾ö˼·£º
googleÁËһϣ¬¾Ý˵2005ÊÇÖ§³ÖµÄ£¬ËùÒÔÏÂÏÂÀ´¿´¿´
ÏÂÔصØÖ·£ºurl£ºhttp://download.microsoft.com/download/2/8/9/289dd6a3-eeeb-46dc-9045-d0c6b59bfbc1/sqljdbc_1.1.1501.101_chs.exe
ʹÓÃС½á£º
1.2005jdbcÇý¶¯ÊÇÖ§³Öjdbc 3.0 µÄ¡£Ò²¾ÍÊÇ˵£¬µÄÈ·Ö§³ÖgetGeneratedKeys()·½·¨¡£
2.2005jdbcÇý¶¯urlºÍ°ü×éÖ¯±ä¶¯½Ï´ó¡£
¾ÙÀý¶Ô±È£º
================
2000
================
url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=mydb;SelectMethod=cursor"
driverClassName="com.microsoft.sqlserver.jdbc.SQLServerDriver"
================
2005
================
url="jdbc:sqlserver://localhost:1433;DatabaseName=mydb;SelectMethod=cursor"
driverClassName="com.microsoft.jdbc.sqlserver.SQLServerDriver"
¼ÙÈçûעÒâÕâµã£¬±Ø½«³öÏÖÒì³££ºCannot load JDBC driver class'com.microsoft.jdbc.sqlserver.SQLServerDriver'
×öºÃµÚ¶þ²½£¬³öÏÖ
3.°üµÄλÖ㺻·¾³±äÁ¿CLASSPATH²»ÊDZØÐëµÄ¡£µ«sqljdbc.jar±ØÐë·ÅÖÃÔÚtomcat/common/libÖУ¨¼ÙÈçÊÇ×âÓÿռ䣬¿ÉÄܵøú¶Ô·½ÉÌÁ¿ÁË£¬¿´ÊÇ·ñÖ§³Ö2005µÄÇý¶¯£©¡£
·ñÔò»á·¢ÉúÒì³££ºCannot load JDBC driver class'com.microsoft.sqlserver.jdbc.SQLServerDriver'
²âÊÔʾÀý·½·¨£º
public String executeUpdate(String sql) throws SQLException ...{
Connection conn = getConnection();
PreparedStatement pstmt = null;
try ...{
/**//*×¢Ò⣺jdbc3.0ÌṩÁËStatement.RETURN_GENERATED_KEYS"ÓÃÀ´Ö¸Ã÷ÐèÒª´ÓStatementÖлñµÃ×Ô¶¯Ôö³¤ÁÐÖµ£¬
¼ÙÈç²»ÅäÖøòÎÊý£¬ÔÚÖ´ÐÐgetGeneratedKeys()ʱ»áÅ׳öÒì³££º"Ö»ÓÐÔËÐиÃÓï¾ä,Éú³ÉµÄ


Ïà¹ØÎĵµ£º

sqlÌâÖеÄÖÖÖÖ

ÔÚ×ösqlÌâʱ£¬ÎÒÃÇ×îÅÂÓöµ½Ìõ¼þ¸´ÔӵIJéѯÓï¾ä£¬ÒòΪ´ó¶àʱºòÐèÒªÁ½Èý¸ö×Ó²éѯÀ´ÊµÏÖ£¬
¶ø´ó¶àÊýͬѧ£¬¿ÉÒÔ˵¶¼±È½ÏÅÂ×Ó²éѯµÄ£¬ÒÔÇ°ÎÒÒ²±»ÕâЩÌâĿŪµÄÔÆÀïÎíÀïµÄ£¬
²»¹ý×ö¶àÁËÕâÀàµÄÌâÄ¿ºó·¢ÏÖ£¬ÆäʵҲÓÐÒ»¶¨¹æÂÉ£¬ÎÒÃÇ¿ÉÒÔ×ܽáÒ»Ì×ÊʺÏ×Ô¼ºµÄ·½·¨À´´¦Àí£¬
ÏÂÃæʱÎÒ¶Ô¸ÃÀàÌâÄ¿µÄ´¦Àí·½·¨£º
ÓйºÎï±íÈçÏ£º
ÌâÄ¿£º ²é ......

SQL SERVER 2005 °²×°´íÎó½â¾öÁË~

½ñÌìÔÚһ̨Ðé»úÉÏ°²×° sql server 2005£¬¾ÓÈ»±¨1´íÁË£¨ÎÞÓïÁË£¬×°Õâ¸ö¶«Î÷¶¼Åª²»ºÃ%>_<%£©¿ªÊ¼ÒÔΪÊÇÒòΪADÓòµÄÔ­Òò£¬ºóÀ´É¾µôÓòÓÖÖؽ¨Óò£¬È»ºóÔÙ×°£¬ÓÖ±¨2´í£¬ÓÚÊÇÎʱðÈËËÑË÷µÈµÈ£¬ÕÒµ½Ô­Òò˵ҪÖØÐÂ×¢²áinstaller£¬×îÖÕ°²×°³É¹¦ÁË£¬º¦ÎÒ¼Ó°àŪµÄ£¬¸ßÐ˵ÄÊÇ°²×°ºÃÀ²£¬¿ÉÊÇÎÒûÓÐŪÃ÷°×µ½µ×ÊÇɶԭÒòµ¼ÖÂsql°²×°²»ÁËÄØ£ ......

×ÔÔö×ֶεÄ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 t ......

SQL SERVER ºÍEXCELµÄÊý¾Ýµ¼Èëµ¼³ö

 SQL SERVER ºÍEXCELµÄÊý¾Ýµ¼Èëµ¼³ö
1¡¢ÔÚSQL SERVERÀï²éѯExcelÊý¾Ý:
-- ======================================================
SELECT *
from OpenDataSource( 'Microsoft.Jet.OLEDB.4.0',
'Data Source="c:\book1.xls";User ID=Admin;Password=;Extended properties=Excel 5.0')...[Sheet1$]
ÏÂÃæÊǸö²éÑ ......

SQLÃæÊÔ

1.Ò»µÀSQLÓï¾äÃæÊÔÌ⣬¹ØÓÚgroup by
±íÄÚÈÝ£º
2005-05-09 ʤ
2005-05-09 ʤ
2005-05-09 ¸º
2005-05-09 ¸º
2005-05-10 ʤ
2005-05-10 ¸º
2005-05-10 ¸º
Èç¹ûÒªÉú³ÉÏÂÁнá¹û, ¸ÃÈçºÎдsqlÓï¾ä?
            ʤ ¸º
2005-05-09 2 2
2005-05-10 ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ