I am trying to move from tomcat standalone to wildfly 11.
I am stuck trying to get connectivity to a mariadb ( fka mysql ).
I followed all the steps to install the mysql-connector-java-5.1.45.jar file
NOTE: mariadb version is 10.2.9-3
Updated standalone.xml to setup the datasource.
I event used the admin console to test the datasource connectivity and it reports "success".
However, in my java class derived from HttpServlet, and exception is thrown trying to connect to the mariadb:
org.h2.jdbc.JdbcSQLException: Table "TESTME" not found; SQL statement:
Why is wildfly using the "h2" database instead of mysql connection class?
Here is my java code:
try {
Context initCtx = new InitialContext();
System.out.println("Call lookup context for java:/comp/env ...");
Context envCtx = (Context) initCtx.lookup("java:comp/env");
System.out.println("Call lookup for DataSource jdbc/TEST_DATABASE ...");
/* lookup using the jndi-name */
ds = (DataSource) envCtx.lookup("jdbc/TEST_DATABASE");
System.out.println("ValidateUser: DataSource Ready!");
System.out.println(ds.toString());
try {
m_mysql_conn = ds.getConnection();
System.out.println("ListService: Got Connection OK!");
}
catch (Exception x)
{
System.out.println("ListService: getConnection:EXCEPTION - " + x );
}
}
catch (Exception e)
{
System.out.println("EXCEPTION - " + e );
e.printStackTrace();
throw e;
}
java.sql.Connection conn = m_mysql_conn;
// This line throws the exception
PreparedStatement pst = conn.prepareStatement("Select field1, field2, from test_table where field1=? and field2=?");