新书推介:《语义网技术体系》
作者:瞿裕忠,胡伟,程龚
   >>中国XML论坛<<     W3CHINA.ORG讨论区     计算机科学论坛     SOAChina论坛     Blog     开放翻译计划     新浪微博  
 
  • 首页
  • 登录
  • 注册
  • 软件下载
  • 资料下载
  • 核心成员
  • 帮助
  •   Add to Google

    >> XML与各种文件格式的相互转换及相关工具。 word to xml, xml to word, html to xml, xml to pdf,
    csv to xml, rtf to xml, text to xml, xml to text, xls to xml, xml to xls
    FOP
    [返回] 中文XML论坛 - 专业的XML技术讨论区XML.ORG.CN讨论区 - XML技术『 WORD to XML, HTML to XML 』 → 如何将XML数据导入数据库 查看新帖用户列表

      发表一个新主题  发表一个新投票  回复主题  (订阅本版) 您是本帖的第 13131 个阅读者浏览上一篇主题  刷新本主题   树形显示贴子 浏览下一篇主题
     * 贴子主题: 如何将XML数据导入数据库 举报  打印  推荐  IE收藏夹 
       本主题类别:     
     peipei 美女呀,离线,快来找我吧!
      
      
      等级:大一新生
      文章:0
      积分:56
      门派:XML.ORG.CN
      注册:2005/4/20

    姓名:(无权查看)
    城市:(无权查看)
    院校:(无权查看)
    给peipei发送一个短消息 把peipei加入好友 查看peipei的个人资料 搜索peipei在『 WORD to XML, HTML to XML 』的所有贴子 引用回复这个贴子 回复这个贴子 查看peipei的博客楼主
    发贴心情 如何将XML数据导入数据库

    各位高手,能否教我如何将XML数据导入数据库啊,我在做毕业设计,急死我了

       收藏   分享  
    顶(0)
      




    点击查看用户来源及管理<br>发贴IP:*.*.*.* 2005/4/20 4:44:00
     
     cxh0926 帅哥哟,离线,有人找我吗?
      
      
      等级:大一(猛啃高等数学)
      文章:20
      积分:136
      门派:XML.ORG.CN
      注册:2005/3/11

    姓名:(无权查看)
    城市:(无权查看)
    院校:(无权查看)
    给cxh0926发送一个短消息 把cxh0926加入好友 查看cxh0926的个人资料 搜索cxh0926在『 WORD to XML, HTML to XML 』的所有贴子 引用回复这个贴子 回复这个贴子 查看cxh0926的博客2
    发贴心情 
    顶起。希望高手来解决下,我也正要问的!
    点击查看用户来源及管理<br>发贴IP:*.*.*.* 2005/5/5 22:22:00
     
     CB1058 帅哥哟,离线,有人找我吗?
      
      
      等级:大一新生
      文章:1
      积分:59
      门派:XML.ORG.CN
      注册:2005/5/6

    姓名:(无权查看)
    城市:(无权查看)
    院校:(无权查看)
    给CB1058发送一个短消息 把CB1058加入好友 查看CB1058的个人资料 搜索CB1058在『 WORD to XML, HTML to XML 』的所有贴子 引用回复这个贴子 回复这个贴子 查看CB1058的博客3
    发贴心情 
    so do I...
    点击查看用户来源及管理<br>发贴IP:*.*.*.* 2005/5/6 19:05:00
     
     linyan 美女呀,离线,快来找我吧!
      
      
      等级:大一新生
      文章:1
      积分:58
      门派:XML.ORG.CN
      注册:2005/5/20

    姓名:(无权查看)
    城市:(无权查看)
    院校:(无权查看)
    给linyan发送一个短消息 把linyan加入好友 查看linyan的个人资料 搜索linyan在『 WORD to XML, HTML to XML 』的所有贴子 引用回复这个贴子 回复这个贴子 查看linyan的博客4
    发贴心情 
    我也是别人教的,是做毕业设计用的,或许可以看看用得着
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.SQLException;
    import java.sql.Statement;

    public class connnect1 {
     String driverName = "com.mysql.jdbc.Driver";
     String databaseUrl = "jdbc:mysql://localhost:3306/ly";
     String user = "java";
     String password = "java";
     static Statement stat =null;
     static Connection con = null;
     
     public void conn(){
      
      try {
       Class.forName(driverName);
       System.out.println("成功加载Mysql数据库驱动!");
      } catch (ClassNotFoundException e) {
       System.out.println("加载Mysql数据库驱动失败!");
       System.out.println(e.getMessage());
       return;
      }
      try {
       con = DriverManager.getConnection(databaseUrl, user,
         password);
       System.out.println("数据库连接成功!");
      stat = con.createStatement();
       
    //   System.out.println(otherversions);
      
       
      } catch (SQLException e) {
       System.out.println("数据库连接失败!");
       System.err.println("SQLExecption: " + e.getMessage());
       return;
      }
     }
    public void ineart_Data(String virusname, String otherversions,
      String alias, String details) throws SQLException {
     String insertData = ("INSERT INTO kav(virusname,otherversions,alias,Details)"
       + "VALUES('"
       + virusname
       + "','"
       + otherversions
       + "','"
       + alias + "','" + details + "')");
     stat.executeQuery(insertData);

    }
    public void close() throws SQLException{
     stat.close();
     con.close();
    }
    }

    点击查看用户来源及管理<br>发贴IP:*.*.*.* 2005/5/20 15:14:00
     
     11924ef 帅哥哟,离线,有人找我吗?
      
      
      等级:大一新生
      文章:11
      积分:98
      门派:XML.ORG.CN
      注册:2005/3/30

    姓名:(无权查看)
    城市:(无权查看)
    院校:(无权查看)
    给11924ef发送一个短消息 把11924ef加入好友 查看11924ef的个人资料 搜索11924ef在『 WORD to XML, HTML to XML 』的所有贴子 引用回复这个贴子 回复这个贴子 查看11924ef的博客5
    发贴心情 
    以下是引用linyan在2005-5-20 15:14:03的发言:
    我也是别人教的,是做毕业设计用的,或许可以看看用得着
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.SQLException;
    import java.sql.Statement;

    public class connnect1 {
      String driverName = "com.mysql.jdbc.Driver";
      String databaseUrl = "jdbc:mysql://localhost:3306/ly";
      String user = "java";
      String password = "java";
      static Statement stat =null;
      static Connection con = null;
      
      public void conn(){
       
       try {
        Class.forName(driverName);
        System.out.println("成功加载Mysql数据库驱动!");
       } catch (ClassNotFoundException e) {
        System.out.println("加载Mysql数据库驱动失败!");
        System.out.println(e.getMessage());
        return;
       }
       try {
        con = DriverManager.getConnection(databaseUrl, user,
          password);
        System.out.println("数据库连接成功!");
       stat = con.createStatement();
        
    //   System.out.println(otherversions);
       
        
       } catch (SQLException e) {
        System.out.println("数据库连接失败!");
        System.err.println("SQLExecption: " + e.getMessage());
        return;
       }
      }
    public void ineart_Data(String virusname, String otherversions,
       String alias, String details) throws SQLException {
      String insertData = ("INSERT INTO kav(virusname,otherversions,alias,Details)"
        + "VALUES('"
        + virusname
        + "','"
        + otherversions
        + "','"
        + alias + "','" + details + "')");
      stat.executeQuery(insertData);

    }
    public void close() throws SQLException{
      stat.close();
      con.close();
    }
    }



    是在什么地方引用这段话呢?在xml中?
    点击查看用户来源及管理<br>发贴IP:*.*.*.* 2005/5/21 11:27:00
     
     wangqiwu4585 帅哥哟,离线,有人找我吗?
      
      
      等级:大一新生
      文章:0
      积分:56
      门派:XML.ORG.CN
      注册:2005/5/6

    姓名:(无权查看)
    城市:(无权查看)
    院校:(无权查看)
    给wangqiwu4585发送一个短消息 把wangqiwu4585加入好友 查看wangqiwu4585的个人资料 搜索wangqiwu4585在『 WORD to XML, HTML to XML 』的所有贴子 引用回复这个贴子 回复这个贴子 查看wangqiwu4585的博客6
    发贴心情 
    不知道有没有vb做的,请赐教啊!!
    点击查看用户来源及管理<br>发贴IP:*.*.*.* 2005/6/3 11:37:00
     
     kiy6585 帅哥哟,离线,有人找我吗?
      
      
      等级:大一新生
      文章:1
      积分:60
      门派:XML.ORG.CN
      注册:2005/6/13

    姓名:(无权查看)
    城市:(无权查看)
    院校:(无权查看)
    给kiy6585发送一个短消息 把kiy6585加入好友 查看kiy6585的个人资料 搜索kiy6585在『 WORD to XML, HTML to XML 』的所有贴子 引用回复这个贴子 回复这个贴子 查看kiy6585的博客7
    发贴心情 
    对啊!怎么都不用vb.net做的呢?
    点击查看用户来源及管理<br>发贴IP:*.*.*.* 2005/6/13 23:52:00
     
     jx27 帅哥哟,离线,有人找我吗?
      
      
      等级:大二期末(汇编考了97分!)
      文章:37
      积分:447
      门派:XML.ORG.CN
      注册:2005/6/15

    姓名:(无权查看)
    城市:(无权查看)
    院校:(无权查看)
    给jx27发送一个短消息 把jx27加入好友 查看jx27的个人资料 搜索jx27在『 WORD to XML, HTML to XML 』的所有贴子 引用回复这个贴子 回复这个贴子 查看jx27的博客8
    发贴心情 
    以下是我的用XSLT把XML的数据输入数据库(MY SQL)的例子:

    <xsl:stylesheet  xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
      <xsl:output method = "text" indent = "yes"/>
      <xsl:template match = "/" >
      <xsl:apply-templates select="*"/>
      </xsl:template>
      <!-- get the value to insert into the table "Qnre" -->
      <xsl:template match = "Qnre">
        <xsl:text>insert into Qnre values ('</xsl:text>
        <xsl:value-of select="@id"/>
        <xsl:text>','</xsl:text>
        <xsl:value-of select="@client"/>
        <xsl:text>','</xsl:text>
        <xsl:value-of select="@author"/>
        <xsl:text>','</xsl:text>
        <xsl:value-of select="@contact"/>
        <xsl:text>','</xsl:text>
        <xsl:value-of select="@version"/>
        <xsl:text>','</xsl:text>
        <xsl:value-of select="@topic"/>
        <xsl:text>','</xsl:text>
        <xsl:value-of select="@date"/>
        <xsl:text>','</xsl:text>
        <xsl:value-of select="Qtitle"/>
        <xsl:text>','</xsl:text>
        <xsl:value-of select="Qtitle/@clientlogo"/>
        <xsl:text>','</xsl:text>
        <xsl:value-of select="Qintro/@privacy"/>
        <xsl:text>','</xsl:text>
        <xsl:value-of select="Qintro/@heading"/>
        <xsl:text>','</xsl:text>
        <xsl:value-of select="Qintro/@para"/>
        <xsl:text>','</xsl:text>
        <xsl:value-of select="Qintro/@Qitem"/>
        <xsl:text>','</xsl:text>
        <xsl:value-of select="Qbody/@action"/>
        <xsl:text>','</xsl:text>
        <xsl:value-of select="Qbody/@uploads"/>
        <xsl:text>','</xsl:text>
        <xsl:value-of select="Qbody/@bid"/>
        <xsl:text>');
    </xsl:text>
        <!-- set to <Qsection> -->
        <xsl:apply-templates select="Qbody/Qsection"/>
      </xsl:template>
      <!-- get the value to insert into the table "Qsection" -->
      <xsl:template match = "Qsection">
       <xsl:text>insert into Qsection values ('</xsl:text>
       <xsl:value-of select="/Qnre/@id"/>
       <xsl:text>','</xsl:text>
       <xsl:value-of select="@sid"/>
       <xsl:text>','</xsl:text>
       <xsl:value-of select="Qintro/Qprivacy"/>
        <xsl:text>','</xsl:text>
        <xsl:value-of select="Qintro/Qheading"/>
        <xsl:text>','</xsl:text>
        <xsl:value-of select="Qintro/Qpara"/>
        <xsl:text>','</xsl:text>
        <xsl:value-of select="Qintro/Qitem"/>
        <xsl:text>','</xsl:text>
        <xsl:value-of select="goto"/>
        <xsl:text>');
    </xsl:text>
        <!-- set to <Question> -->
        <xsl:apply-templates select="Question"/>
      </xsl:template>
      <!-- get the value to insert into the table "Question" -->
      <xsl:template match="Question">
        <xsl:text>insert into Question values ('</xsl:text>
        <xsl:value-of select="/Qnre/@id"/>
        <xsl:text>','</xsl:text>
        <!-- set to <Qsection> -->
        <xsl:value-of select="../@sid"/>
        <xsl:text>','</xsl:text>
       <xsl:value-of select="@qid"/>
        <xsl:text>','</xsl:text>
        <xsl:value-of select="@kind"/>
        <xsl:text>','</xsl:text>
        <xsl:value-of select="Qintro/Qprivacy"/>
        <xsl:text>','</xsl:text>
        <xsl:value-of select="Qintro/Qheading"/>
        <xsl:text>','</xsl:text>
        <xsl:value-of select="Qintro/Qpara"/>
        <xsl:text>','</xsl:text>
        <xsl:value-of select="Qintro/Qitem"/>
        <xsl:text>','</xsl:text>
        <xsl:value-of select="Qtext"/>
        <xsl:text>','</xsl:text>
        <xsl:value-of select="Qanswer/Qother"/>
        <xsl:text>','</xsl:text>
        <xsl:value-of select="Qanswer/@answertype"/>
        <xsl:text>','</xsl:text>
        <xsl:value-of select="Qanswer/Qlink/@goto"/>
        <xsl:text>');
    </xsl:text>
        <!-- set to <Qchoice> -->
        <xsl:apply-templates select="Qanswer/Qchoice"/>
      </xsl:template>
      <!-- get the value to insert into the table "Qchoice" -->
      <xsl:template match="Qchoice">
        <xsl:text>insert into Qchoice values ('</xsl:text>
        <xsl:value-of select="/Qnre/@id"/>
        <xsl:text>','</xsl:text>
        <xsl:value-of select="/Qnre/Qbody/Qsection/@sid"/>
        <xsl:text>','</xsl:text>
        <!-- set to <Question> -->
        <xsl:value-of select="../../@qid"/>
        <xsl:text>','</xsl:text>
        <xsl:value-of select="@val"/>
        <xsl:text>','</xsl:text>
        <xsl:value-of select="/Qother/Qlink/@goto"/>
        <xsl:text>','</xsl:text>
        <xsl:value-of select="."/>
        <xsl:text>');
    </xsl:text>
        </xsl:template>
    </xsl:stylesheet>

    /===========
    输出结果文件可以另存为SQL FILE。然后在LINUX的COMMEND LINE里直接输入文件名就能
    自动INSERT INTO DATABASE了。

    点击查看用户来源及管理<br>发贴IP:*.*.*.* 2005/6/17 7:56:00
     
     amyflower 美女呀,离线,快来找我吧!
      
      
      等级:大一新生
      文章:3
      积分:65
      门派:XML.ORG.CN
      注册:2005/6/17

    姓名:(无权查看)
    城市:(无权查看)
    院校:(无权查看)
    给amyflower发送一个短消息 把amyflower加入好友 查看amyflower的个人资料 搜索amyflower在『 WORD to XML, HTML to XML 』的所有贴子 引用回复这个贴子 回复这个贴子 查看amyflower的博客9
    发贴心情 
    可以用一用JBuilderX

    ----------------------------------------------
    为中国的软件事业而奋斗终身!

    点击查看用户来源及管理<br>发贴IP:*.*.*.* 2005/6/17 10:58:00
     
     GoogleAdSense
      
      
      等级:大一新生
      文章:1
      积分:50
      门派:无门无派
      院校:未填写
      注册:2007-01-01
    给Google AdSense发送一个短消息 把Google AdSense加入好友 查看Google AdSense的个人资料 搜索Google AdSense在『 WORD to XML, HTML to XML 』的所有贴子 访问Google AdSense的主页 引用回复这个贴子 回复这个贴子 查看Google AdSense的博客广告
    2024/5/3 17:23:26

    本主题贴数9,分页: [1]

    管理选项修改tag | 锁定 | 解锁 | 提升 | 删除 | 移动 | 固顶 | 总固顶 | 奖励 | 惩罚 | 发布公告
    W3C Contributing Supporter! W 3 C h i n a ( since 2003 ) 旗 下 站 点
    苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》
    6,257.813ms