Sqlserver£º´ÓXMLÎļþÖжÁÈ¡ÅäÖÃÐÅÏ¢
ÈçºÎÔÚSqlserverÖдÓÍⲿXMLÎļþÖжÁÈ¡ÅäÖÃÐÅÏ¢ÄØ£¿¸ÃÎÊÌâÔ´×ÔÒ»¼ÒÆóÒµµÄ±ÊÊÔÐÅÏ¢ÓиС£
Ò»xmlÎļþÄÚÈÝ£º
<?xml version="1.0" encoding="utf-8"?>
<root>
<db name="ClientDB1" datasize="512MB" datagrowth="100MB" logsize="100MB" loggrowth ="50MB">
</db>
<db name="ClientDB2" datasize="1536MB" datagrowth="200MB" logsize="100MB" loggrowth ="100MB">
</db>
<db name="ClientDBN" datasize="1024MB" datagrowth="200MB" logsize="100MB" loggrowth ="80MB">
</db>
</root>
½Å±¾£º
declare @x xml
declare @hdocid int
/*´ÓÍⲿÎļþ¶ÁÈ¡ÎļþÄÚÈÝ
ÓкܶàÖÖ·½Ê½£º
xp_cmdshell µ÷ÓòÙ×÷ϵͳµÄÏÔʽÎı¾ÎļþÄÚÈݵÄÀ©Õ¹´æ´¢¹ý³Ì¡£
bcp.exe µ¼Èëµ¼³ö¹¤¾ß
openrowset¶ÁÈëÎı¾ÎļþÄÚÈÝ£¨sql2005µÃµ½ÔöÇ¿£©
bulk insertÓï¾ä
*/
select @x=bulkcolumn
from openrowset(bulk 'c:\db_conifig.xml',SINGLE_CLOB ) as t¡¡¡¡--sqlserver2005µÄÔöÇ¿bulkÓï·¨
--½âÎö³ÉxmlÊ÷ÐÎÎĵµÔÚÄÚ´æÖÐ
exec sp_xml_preparedocument @hdocid output,@x
--sqlserver½âÎö³É½á¹û¼¯µÄÐÎʽ£¬±ãÓÚʹÓ᣻òÕßÖ±½ÓÀûÓÃxmlÀàÐ͵ķ½·¨½âÎö£¡
select *
from openxml(@hdocid,'/root/db') with (name varchar(50),datasize varchar(50),datagrowth varchar(50),logsize varchar(50),loggrowth varchar(50))
Ïà¹ØÎĵµ£º
==========================================
xmlÎļþ
£¼?xml version="1.0" encoding="GB2312"?£¾
£¼RESULT£¾
£¼VALUE£¾
¡¡¡¡ £¼NO£¾A1234£¼/NO£¾
¡¡¡¡ £¼ADDR£¾ËÄ´¨Ê¡XXÏØXXÕòXX·X¶ÎXXºÅ£¼/ADDR£¾
£¼/VALUE£¾
£¼VALUE£¾
¡¡¡¡ £¼NO£¾B1234£¼/NO£¾
¡¡ ¡¡£¼ADDR£¾ËÄ´¨Ê¡XXÊÐXXÏçXX ......
jdbcÅäÖÃÓï¾äΪ: jdbc:microsoft:sqlserver://server_name:1433
ÈçÔËÐгÌÐòʱ³öÏÖ "Error establishing socket" ´íÎó,ÔòÓ¦½øÐÐÈçϵ÷ÊÔ:
1 ¼ì²éSQL SERVER ÊÇ·ñÔÊÐíÔ¶³Ì·ÃÎÊ.¾ßÌå²½Öè:
1)´ò¿ª"ÆóÒµ¹ÜÀíÆ÷",´ò¿ª¿ØÖÆ̨¸ùĿ¼>SQL Server ×é>Êý¾Ý¿â
2)ÔÚÏàÓ¦"Êý¾Ý¿â"Éϵ¥»÷ÓÒ¼ü,Ñ¡Ôñ"ÊôÐÔ"
3)Ñ¡Ôñ"Á¬½Ó"Ñ ......
ʹÓÃXML changeÐÞ¸ÄxmlÎļþµÄ»ù±¾²½Öè
(½öÏÞÓÚInstallscript MSIÏîÄ¿ÒÔ¼°Basic MSIÏîÄ¿)
1.µ¼ÈëXMLÎļþ¡£ÔÚSystem ConfigurationÊÔͼÖÐÑ¡ÔñXML File Changes£¬ÓÒ¼üXML
File¡£Ñ¡ÔñImport£¬¿ÉÒÔÆô¶¯Import XML
wizard¡£NextÖ®ºó£¬Ñ¡ÔñÐèÒªµ¼ÈëµÄXMLÎļþ£¨¿ÉÒÔÔÚÏÂÀ¿òÖÐÑ¡ÔñÀàÐÍ£©¡£NextÖ®ºó£¬Select
ALL¡£Èç¹ûÑ¡Ôñ²¿·Ö£ ......
//»ñÈ¡Êý¾Ý¿âÊý¾Ý·µ»Ølist
public List queryAll(int fcateId) {
List list = new ArrayList();
String sql = "select * from g_Account where fCateID=? order by fCode";
Connection con = SqlHelp.getConn();//»ñµÃÁ¬½Ó£¬sqlhelp×Ô¼ºÐ´µÄ¹¤¾ßÀà
PreparedStatement pst = null;
ResultSet rs = null;
......
ÈçºÎ¼ÓÔØÓÐÍâ¹úºÍÌØÊâ×Ö·ûµÄÎĵµ£¿
¡¡¡¡Îĵµ¿ÉÒÔ°üº¬Íâ¹ú×Ö·û£¬ÀýÈ磺
¡¡¡¡foreign characters (úóí?)
¡¡¡¡ÀýÈç íá µÄÍâ¹ú×Ö·û±ØÐëÔÚÇ°Ãæ¼ÓÉÏ escape ÐòÁС£Íâ¹ú×Ö·û¿ÉÒÔÊÇ UTF-8 ±àÂë»òÓò»Í¬±àÂëÖ¸¶¨£¬ÈçÏÂËùʾ£º
¡¡¡¡foreign characters (íá)
¡¡¡ ......