• tomcat数据源配置


    MySQL数据库在使用汉字进行查询的时候容易出错,如查询:

    select * from e_document where E_WENHAO   like '山大%'

    明明在数据库中有相关数据,但是却查询不出结果。这时候需要在建立连接的时候,将连接改为如下形式:

    DriverManager.getConnection("jdbc:mysql://localhost/edoas2?user=root&password=&useUnicode=true&characterEncoding=GB2312")

    问题解决。但是在tomcat中使用datasource数据源来配置连接,这时候如果将连接数据源中的:

    url="jdbc:mysql://192.168.1.6/123paibbs?useUnicode=true&characterEncoding=GBK"
    由于tomcat得xml文件解析问题,tomcat启动会产生错误:

    Parse Fatal Error at line 373 column 80: The reference to entity "characterEncoding" must end with the ';' delimiter.

    这时候需要将url改为如下形式:

    url="jdbc:mysql://127.0.0.1:3306/edoas2?useUnicode=true&characterEncoding=GB2312"

    最后Server.xml配置如下:

    <Resource
          name="java/mysql"
          type="javax.sql.DataSource"    
          driverClassName="com.mysql.jdbc.Driver"
          maxIdle="2"
          maxWait="5000"     
          username="root"
          url="jdbc:mysql://127.0.0.1:3306/edoas2?useUnicode=true&amp;characterEncoding=GB2312"
          password=""
          maxActive="20"/>

    web.xml配置如:

       <resource-ref>
        <description>MySQL DB Connection Pool</description>
        <res-ref-name>java/mysql</res-ref-name>
        <res-type>javax.sql.DataSource</res-type>
        <res-auth>Container</res-auth>
        <res-sharing-scope>Shareable</res-sharing-scope>
       </resource-ref>

    context.xml配置为:

    <ResourceLink
       name="java/mysql"
       type="javax.sql.DataSource"
       global="java/mysql"/>

  • 相关阅读:
    linux 操作 I/O 端口
    linux I/O 端口分配
    大数问题:求n的阶乘
    POJ 2586 Y2K Accounting Bug
    每天一点儿Java--ComboBox
    android的一些控件
    解决Linux(ubuntu),windows双系统重装后恢复开机选单
    Mysql数据备份与恢复
    log4net 存储到oracle 调试 Could not load type [log4net.Appender.OracleAppender]
    POJ 2533 Longest Ordered Subsequence
  • 原文地址:https://www.cnblogs.com/macula7/p/1960470.html
Copyright © 2020-2023  润新知