½« Session ·ÅÈë SQLServer ±£´æ
SQLServer ģʽ¾ÍÊÇ£¬°ÑSession ´æ·ÅÔÚ SQL Server Êý¾Ý¿âÀעÒâ²»ÊÇ Oracle £¬¶¯¶¯½ÅÖº¶¼Äܲµ½ÔÒòÀ²£©£¬ÏÂÃ濪ʼ˵Ã÷Ò»ÏÂÉèÖõľßÌå²½Ö裺
1¡¢ Æô¶¯Ïà¹ØµÄÊý¾Ý¿â·þÎñ£¨Èçͼ£©
ÔËÐÐSQL Server ·þÎñ¹ÜÀíÆ÷ → Æô¶¯ SQL Server £¨×îºÃÉèΪ¿ª»ú×Ô¶¯ÔËÐУ© → Æô¶¯ SQL Server Agent ·þÎñ£¨×îºÃÉèΪ¿ª»ú×Ô¶¯ÔËÐУ©
×¢ÒâÊÂÏ
a)¡¢×¢ÒâÆô¶¯Ë³Ðò£¬Ò²¿Éͨ¹ýÏÂÁз½Ê½ÉèÖ㺠ÓÒ¼üµã»÷“ÎҵĵçÄÔ”→ ¹ÜÀí → ·þÎñÓëÓ¦ÓóÌÐò → ·þÎñ → ÕÒµ½“MSSQLSERVER”Óë“SQLSERVERAGENT” → Æô¶¯²¢ÉèÖÃÆô¶¯ÀàÐÍΪ“×Ô¶¯”
b)¡¢SQL Server AgentÔÚ´Ë´¦µÄ×÷ÓÃÊÇÇå³ýÊý¾Ý¿âÖÐÒѹýÆÚµÄ Session
2¡¢ ½¨Á¢´æ·Å Session µÄ DataBase
ÔËÐГSQL ²éѯ·ÖÎöÆ÷”→ ʹÓÓsa”»òÊÇÓµÓГmaster”µÄ db_owner ȨÏÞµÄÓû§µÇ¼Êý¾Ý¿â → ´ò¿ª²éѯÎļþ C:\WINNT\Microsoft.NET\Framework\v1.1.4322\InstallSqlState.sql £¨´æ·ÅÔÚ Windows ϵͳĿ¼µÄ .Net °²×°Ä¿Â¼Ï¿ÉÕÒµ½£© → Ö±½ÓÔËÐиà sql ½Å±¾ → Ë¢ÐÂÊý¾Ý¿â¼´¿É¿´µ½ÃûΪ ASPState µÄ DataBase
3¡¢ ½¨Á¢Á¬½ÓÊý¾Ý¿â ASPState µÄÓû§£¬²¢Îª´ËÓû§ÊÚȨ£¨´Ë²½Öè¿ÉÌø¹ý£©
½øÐд˲½µÄÔÒòÊÇ£ºÒ»ÊDz»ÏëÔÚ Web.config ÖгöÏÖ sa µÄÃÜÂ룻¶þÊÇ tempdb ÔÚÊý¾Ý¿âÆô¶¯ºó½ö±£Áô sa Ò»¸öÕʺŵÄʹÓÃȨÏÞ£¬ÆäÓàÕʺŵÄȨÏÞͳͳ±»Çå³ý£¬µ«±£´æ SessionÓÖÐèÒªÓõ½´Ë DataBase£»
A)¡¢ÔËÐÐ SQL Server µÄÆóÒµ¹ÜÀíÆ÷ → Õ¹¿ªÊý¾Ý¿âµÄ°²È«ÐÔ → ÓÒ»÷“µÇ¼” → н¨“µÇ¼” → ÊäÈë“Ãû³Æ” → Ñ¡Ôñ “SQL Server Éí·ÝÑéÖ¤” → ÊäÈë“ÃÜÂë” → Ö¸¶¨“Êý¾Ý¿â” → µã»÷“Êý¾Ý¿â·ÃÎÊ” → ¹´Ñ¡ “ASPState” → Ñ¡ÖГdb_owner”½ÇÉ« → µã»÷“È·¶¨” → ÔÙÒ»´ÎÊäÈë“ÃÜÂë” → µã»÷“È·¶¨” ºó¼´¿É½¨Á¢ ASPState µÄÓû§£¨´Ë´¦½¨Á¢ÃûΪ“SessionStateUser”£¬ÃÜÂëΪ“123456”µÄ²âÊÔÓû§£©
B)¡¢ÔËÐÐ SQL Server µÄÆóÒµ¹ÜÀíÆ÷ → Õ¹¿ª“¹ÜÀí” → Õ¹¿ª“SQ
Ïà¹ØÎĵµ£º
È«ÎļìË÷ÊǶԴóÊý¾ÝÎı¾½øÐÐË÷Òý£¬ÔÚ½¨Á¢µÄË÷ÒýÖжÔÒª²éÕҵĵ¥´Ê½øÐнøÐÐËÑË÷£¬¶¨Î»ÄÄЩÎı¾Êý¾Ý°üÀ¨ÒªËÑË÷µÄµ¥´Ê¡£Òò´Ë£¬È«ÎļìË÷µÄÈ«²¿¹¤×÷¾ÍÊǽ¨Á¢Ë÷ÒýºÍÔÚË÷ÒýÖÐËÑË÷¶¨Î»£¬ËùÓеŤ×÷¶¼ÊÇΧÈÆÕâÁ½¸öÀ´½øÐеġ£ÏÂÃæ¾ÍÖð¸ö½éÉÜ¡£
¡¡¡¡½¨Á¢È«ÎÄË÷ÒýÖÐÓÐÁ½Ïî·Ç³£ÖØÒª£¬Ò»¸öÊÇÈçºÎ¶ÔÎı¾½øÐзִʣ¬Ò»Êǽ¨Á¢Ë÷ÒýµÄÊý¾Ý½á¹¹¡ ......
Óû§È¨ÏÞ¹ÜÀí
Ò»¡¢·þÎñÆ÷µÇ¼ÕʺźÍÓû§ÕʺŹÜÀí
1.SQL Server·þÎñÆ÷µÇ¼¹ÜÀí
²»¹ÜʹÓÃÄÄÖÖÈÏ֤ģʽ£¬Óû§¶¼±ØÐëÏȾ߱¸ÓÐЧµÄÓû§µÇ¼Õʺš£SQL ServerÓÐÈý¸öĬÈϵÄÓû§µÇ¼Õʺţº¼´sa¡¢Builtin\administratorsºÍguest¡£saÊÇϵͳ¹ÜÀíÔ±(system administrator)µÄ¼ò³Æ£¬ÊÇÒ»¸öÌØÊâµÄÓû§£¬ÔÚSQL ServerϵͳºÍËùÓÐÊý¾Ý¿âÖÐÓ ......
ÔÚƽʱµÄ¹¤×÷¹ý³ÌÖУ¬×÷ΪDBA½ÇÉ«¹ÜÀíÊý¾Ý¿â£¬Í·ÄÔÖеÄÓ¡ÏóÍùÍùÊÇÊý¾Ý¿âʵÀýÃû³Æ£¬¶ø²»»áÈ¥¹ØÐÄServerµÄIP£¬¶ø×÷ΪDeveloperµÄ½ÇÉ«£¬ËûÃÇÍùÍùÏëÖªµÀÖªµÀServer IpºÍ¶Ë¿ÚºÅ¡£ËùÒÔ£¬DBA»á¾³£±»Îʼ°µ½£ºXXXʵÀýµÄIPºÍ¶Ë¿ÚºÅÊÇʲô£¿
Õâ¸öÎÊÌ⣬µ±È»ÎÒÃÇ¿ÉÒÔLoginµ½OS²é¿´IP¡¢Ê¹ÓÃÅäÖƹÜÀí¹¤¾ß»ñÈ¡µ½¶Ë¿ÚºÅ¡£µ«ÊÇ£¬Õâ¸ö·½·¨·Ç ......
sqlserverÊý¾Ý¿â£ºjavaÁ¬½Ósqlserver2005Êý¾Ý¿âÐĵÃÌå»á
Ê×ÏȵÃÏÂÔØÇý¶¯³ÌÐòµ½Î¢ÈíÍøÕ¾ÏÂÔØMicrosoft SQL Server 2005 JDBC Driver 1.2¡¡¡¡½âѹMicrosoft SQL Server 2005 jdbc driver1.2.exe
µÃµ½sqljdbc.jar£¬ÓõÃʱºòÖ±½Ó¼Óµ½classpathÖÐÈ¥.
¡¡ÉèÖÃSQL Server·þÎñÆ÷
·ÀÖ¹³öÏÖ
com.mi ......
eg:
select * from Exception_Log where DATEDIFF(day,OPER_DATE,getdate())<30 ;
/*
oper_date Ϊ±íÖвéѯ³öÀ´µÄʱ¼ä
getdate()ΪSQLServerÀïÃæ»ñµÃϵͳʱ¼äµÄº¯Êý
º¬Ò壺µ±Ç°Ê±¼ä-²éѯ³öÀ´µÄʱ¼äСÓÚ30Ìì
DateDiff¾ßÌåÓ÷¨£º
*/
DateDiff º¯Êý
·µ»ØÁ½¸öÈÕÆÚÖ®¼äµÄʱ¼ä¼ä¸ô¡£
DateDiff(interval, date1, da ......