Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

  • aderosso
    started a topic MySQL Datasource

    MySQL Datasource

    I'm trying to hook up a MySQL data source. I have it working and setting up the DB connection. I verified that the connection works using Spring and getting the db connection from JNDI. However, when I try and load a ds.xml, I get this error:

    Code:
    java.sql.SQLException: java.lang.ClassNotFoundException: com.mysql.jdbc.jdbc2.optional.MysqlDataSource
    I'm not sure why it's trying to load the MySQL driver, I've been using MariaDB. Here's my server.properties:

    Code:
    sql.defaultDatabase.jndi.publish.path:isomorphic/jdbc/defaultDatabase
    # If you want to use Mysql instead, uncomment the following line
    # and comment all other sql.defaultDatabase definitions
    sql.defaultDatabase:Mysql
    sql.defaultDatabase.type:mysql
    sql.defaultDatabase.interface.type:dataSource
    sql.defaultDatabase.driver:org.mariadb.jdbc.MariaDbDataSource
    sql.defaultDatabase.driver.serverName:${db.host}
    sql.defaultDatabase.driver.portNumber:3306
    sql.defaultDatabase.driver.databaseName:${db.name}
    sql.defaultDatabase.driver.user:${db.user}
    sql.defaultDatabase.driver.password:${db.password}
    And my ds.xml

    Code:
    <DataSource ID="Customer"
                serverType="sql"
                tableName="customer"
                autoDeriveSchema="true">
    </DataSource>
    Is there a configuration that I'm missing to tell it to use the correct driver?

  • Clifford26
    replied
    The org.gjt.mm.mysql.Driver class name is also usable for backward compatibility with MM.MySQL, the predecessor of Connector/J. Use this class name when registering the driver, or when configuring a software to use MySQL Connector/J liteblue official
    Last edited by Clifford26; 13th Aug 2019, 02:38.

    Leave a comment:


  • aderosso
    replied
    Thank you, that worked.

    Leave a comment:


  • Isomorphic
    replied
    Change your configuration to:

    Code:
    sql.defaultDatabase:Mysql
    sql.Mysql.type:mysql
    sql.Mysql.interface.type:dataSource
    sql.Mysql.driver:org.mariadb.jdbc.MariaDbDataSource
    sql.Mysql.driver.serverName:${db.host}
    sql.Mysql.driver.portNumber:3306
    sql.Mysql.driver.databaseName:${db.name}
    sql.Mysql.driver.user:${db.user}
    sql.Mysql.driver.password:${db.password}
    Note that the name 'Mysql' that is used as the defaultDatabase name above is just a symbolic name used to select the configuration block. You could call it whatever you want.

    Leave a comment:

Working...
X