Jboss connection pool doesn't connect with the DataBase - mysql

I am using JBoss 7.1, and I'm trying to create a Database Connection Pool through Application Server. I'm using a mysql DB, but I tried also with a Postgre database and the error is just the same. Everything seems to be OK, but when I try to access to the application, it appears an error on console that advises me that the connection with the database was failed. My code is the following:
My Jboss standalone.xml.
<datasource jndi-name="java:jboss/jdbc/exampleDS" pool-name="jdbc/exampleDS" enabled="true" use-java-context="true" use-ccm="true">
<connection-url>jdbc:mysql://127.0.0.1:3306/example?useSSL=false</connection-url>
<driver>mysql-connector-java-5.1.43-bin.jar</driver>
<pool>
<min-pool-size>10</min-pool-size>
<max-pool-size>100</max-pool-size>
<prefill>true</prefill>
</pool>
<security>
<user-name>root</user-name>
<password>password</password>
</security>
<validation>
<valid-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.mysql.MySQLValidConnectionChecker"/>
<exception-sorter class-name="org.jboss.jca.adapters.jdbc.extensions.mysql.MySQLExceptionSorter"/>
</validation>
</datasource>
<driver name="mysql-connector-java-5.1.43-bin.jar" module="com.mysql">
<xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlDataSource</xa-datasource-class>
</driver>
My web.xml
<resource-ref>
<description>example</description>
<res-ref-name>jdbc/exampleDS</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
My javacode
private ServiceLocator() {
try {
this.initCtx = new InitialContext();
this.envCtx = (Context) initCtx.lookup("java:comp/env");
DataSource ds = (DataSource)
envCtx.lookup("jdbc/exampleDS");
} catch (NamingException e) {
ApplicationException apRE = new ApplicationException(ErrorCode.E_JDNI001, e);
LogService.getLog().fatal(apRE.getMessage(), apRE);
throw apRE;
}
}
Finally, when I start my jboss server, none error appears, but the console said that the tables of my DB don't exist.
I appreciate help <3

I had fixed the error.
First thing to do is creating a jboss-web.xml where web.xml, in my case, webapp/WEB-INF. It must be similar to the following:
<jboss-web>
<resource-ref>
<res-ref-name>jdbc/exampleDS</res-ref-name>
<jndi-name>java:jboss/jdbc/exampleDS</jndi-name>
</resource-ref>
</jboss-web>
Once that is created, we must create a module.xml inside of modules->com->mysql->main, containing the following:
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.1" name="com.mysql">
<resources>
<resource-root path="mysql-connector-java-5.1.43-bin.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
</dependencies>
</module>
You have to insert also, the .jar that you used also inside of the main dir.
Regarding the javacode, you need to change the initCtx.lookup("java:comp/env"); for this: initCtx.lookup("java:");
That's all :)

Related

How configure TomEE and JPA

sorry for my bad english, (Im french :-D).
I want work with TomEE for JPA, but my configuration is bad i think.
I receive a exception when i try to connecte to my database (Mysql).
persistence.xml
<persistence-unit name="elevage" transaction-type="JTA">
<provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
<jta-data-source>elevage</jta-data-source>
<non-jta-data-source>elevageUnmanaged</non-jta-data-source>
<class>com.test.ejb.BeanAnimal</class>
<properties>
<property name="openjpa.jdbc.DBDictionary" value="mysql" />
<property name="openjpa.Log" value="DefaultLevel=WARN, Tool=INFO" />
</properties>
</persistence-unit>
tomee.xml
<Resource id="elevage" type="DataSource">
JdbcDriver com.mysql.jdbc.Driver
JdbcUrl jdbc:mysql://localhost:3306/elevage2?useLegacyDatetimeCode=false&serverTimezone=Australia/Sydney&useSSL=false
UserName root
Password pass
JtaManaged true
DefaultAutoCommit false
</Resource>
<Resource id="elevageUnmanaged" type="DataSource">
JdbcDriver com.mysql.jdbc.Driver
JdbcUrl jdbc:mysql://localhost:3306/elevage2?useLegacyDatetimeCode=false&serverTimezone=Australia/Sydney&useSSL=false
UserName root
Password pass
JtaManaged false
</Resource>
Exception
AVERTISSEMENT: Unexpected exception from beforeCompletion; transaction will roll back
<openjpa-2.4.1-r422266:1730418 fatal general error> org.apache.openjpa.persistence.PersistenceException: user lacks privilege or object not found: OPENJPA_SEQUENCE_TABLE {SELECT SEQUENCE_VALUE FROM OPENJPA_SEQUENCE_TABLE WHERE ID = ? FOR UPDATE} [code=-5501, state=42501]
Request is a "SELECT" and i want take all data in my database. I have see documentation but the problem persiste.
Thank all for your answer !
(if you need more file, tell me :-) )
After a long time tearing my hair, I found a solution, if it can save time, here it is:
2 Configurations!
In development:
tomee.xml is not used, it is necessary to configure openejb.xml whose path is specified in the eclipse console, attention, the access is by hidden file
Path for my machine (Linux):
/home/user/eclipse-workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp2/conf/openejb.xml
At the bottom of the file, you have section "Resource", the configuration is identical to tomee.xml (you can find documentation at this adress : documentation for configuration tomee.xml
In production:
we forget openejb.xml, a configuration is identical but in tomee.xml
to finish, here is my configuration:
persistence.xml
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="elevage" transaction-type="JTA">
<provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
<jta-data-source>MyDataBase</jta-data-source>
<non-jta-data-source>MyDataBaseUnmanaged</non-jta-data-source>
<class>com.test.ejb.BeanAnimal</class>
<!-- <class>com.test.ejb.BeanUser</class>-->
<properties>
<property name="openjpa.jdbc.DBDictionary" value="mysql" />
<property name="openjpa.Log" value="DefaultLevel=WARN, Tool=INFO" />
</properties>
</persistence-unit>
openejb.xml (in development) and tomee.xml (in production)
<Resource id="MyDataBase" type="DataSource">
JdbcDriver com.mysql.jdbc.Driver
JdbcUrl jdbc:mysql://localhost:3306/elevage?useLegacyDatetimeCode=false&serverTimezone=Australia/Sydney&useSSL=false
UserName root
Password pass
JtaManaged true
</Resource>
<Resource id="MyDataBaseUnmanaged" type="DataSource">
JdbcDriver com.mysql.jdbc.Driver
JdbcUrl jdbc:mysql://localhost:3306/elevage?useLegacyDatetimeCode=false&serverTimezone=Australia/Sydney&useSSL=false
UserName root
Password pass
JtaManaged false
</Resource>

JNDI lookup for connection pooling

I am trying to get pool of connections using jndi lookup but have a following error: java.sql.SQLException: Cannot create JDBC driver of class '' for connect URL 'null'
My context xml placed in web/WEB-INF folder near web.xml
<?xml version="1.0" encoding="UTF-8"?>
<Context antiJARLocking="true" crossContext="true" reloadable="true" path="patient/account">
<Resource
name="jdbc/pharmacy"
author="Container"
type="javax.sql.DataSource"
maxActive="32"
maxIdle="8"
maxWait="10000"
username="root"
password="23810198vas"
driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/pharmacy" />
</Context>
Context envCtx = new InitialContext();
DataSource ds = (DataSource)envCtx.lookup("java:comp/env/jdbc/pharmacy");
Connection connection = ds.getConnection();
For Tomcat , context.xml should be under META-INF and META-INF folder should be at the same level as WEB-INF folder.

wildfly registering mysql as a datasource

I have been trying to configure mysql as a datasource in wildfly. I am not sure what i am missing out, i get an error on startup .
I have the mysql-connector-java-5.0.8-bin.jar and the module.xml in the folder:
"/wildfly-8.1.0.Final/modules/system/layers/base/com/mysql/main"
below are the files
module.xml
<module xmlns="urn:jboss:module:1.1"
name="com.mysql">
<resources>
<resource-root path="mysql-connector-java-5.0.8.jar"/>
<!-- Insert resources here -->
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
<module name="javax.servlet.api" optional="true"/>
</dependencies>
</module>
standalone.xml
<datasource jndi-name="java:jboss/datasources/ExampleDS" pool-name="ExampleDS" enabled="true" use-java-context="true">
<connection-url>jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE</connection-url>
<driver>h2</driver>
<security>
<user-name>sa</user-name>
<password>sa</password>
</security>
</datasource>
<datasource jta="true" jndi-name="java:jboss/datasources/proj" pool-name="proj" enabled="true" use-java-context="true" use-ccm="true">
<connection-url>jdbc:mysql://localhost:3306</connection-url>
<driver>mysql</driver>
<security>
<user-name>root</user-name>
<password>admin123</password>
</security>
<statement>
<prepared-statement-cache-size>32</prepared-statement-cache-size>
<share-prepared-statements>true</share-prepared-statements>
</statement>
</datasource>
<drivers>
<driver name="mysql" module="com.mysql">
<xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</xa-datasource-class>
</driver>
<driver name="h2" module="com.h2database.h2">
<xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
</driver>
</drivers>
</datasources>
I have tested the jdbc connectivity with a standalone program in eclipse and it worked
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class ConnectSql {
public static void main(String []args){
String userName = "root";
String pass = "admin123";
String url = "jdbc:mysql://localhost/";
String driver ="com.mysql.jdbc.Driver";
String db = "proj";
try{
//registering the driver.
Class.forName(driver);
Connection con = DriverManager.getConnection(url+db,userName,pass);
Statement st = con.createStatement();
ResultSet rs = st.executeQuery("select f_name from t_users");
while(rs.next()){
System.out.println("name :"+rs.getString(1));
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
catch(ClassNotFoundException cnf){
cnf.printStackTrace();
}
}
}
Referred to the below link and modified the module.xml
Wildfly 8.0.0 mysql problems with datasource
Here is a the error log i get on start up
02:45:17,169 ERROR [org.jboss.as.controller.management-operation]
(Controller Boot Thread) JBAS014613: Operation ("add") failed -
address: ([
("subsystem" => "datasources"),
("data-source" => "proj") ]) - failure description: {"JBAS014771: Services with missing/unavailable dependencies" => [
"jboss.data-source.java:jboss/datasources/proj is missing [jboss.jdbc-driver.mysql]",
"jboss.driver-demander.java:jboss/datasources/proj is missing [jboss.jdbc-driver.mysql]" ]} 02:45:17,175 ERROR
[org.jboss.as.controller.management-operation] (Controller Boot
Thread) JBAS014613: Operation ("add") failed - address: ([
("subsystem" => "datasources"),
("data-source" => "proj") ]) - failure description: {
"JBAS014771: Services with missing/unavailable dependencies" => [
"jboss.data-source.java:jboss/datasources/proj is missing [jboss.jdbc-driver.mysql]",
"jboss.driver-demander.java:jboss/datasources/proj is missing [jboss.jdbc-driver.mysql]"
],
"JBAS014879: One or more services were unable to start due to one or more indirect dependencies not being available." => {
"Services that were unable to start:" => [
"jboss.data-source.reference-factory.proj",
"jboss.naming.context.java.jboss.datasources.proj"
],
"Services that may be the cause:" => ["jboss.jdbc-driver.mysql"]
} }
To resolve the mysql datasource configuration issue on Wildfly i used the admin console to add the datasource and test it.
If you login to the web console and find the datasource you tried configuring disable
that a remove it . The standalone.xml and the module.xml get reset to the orginal.
Steps for accessing web console
Configure a new datasource :
name :mysql
JNDI :java:jboss/datasources/proj
Click next and enter the url (i used the below) and click enable and then click test
url : jdbc:mysql://localhost/proj
The test should show success
The changes to the standalone.xml and the module.xml are automatically made .
If you restart the server now it should start without any errors and you should be able to access the database from your web project
I have working configuration of mysql driver on wildfly.
<datasources>
// ...
<drivers>
// ...
<driver name="mysql" module="com.mysql.jdbc">
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
<driver-class>com.mysql.jdbc.Driver</driver-class>
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
<xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</xa-datasource-class>
</driver>
</drivers>
</datasources>
The little difference seems to be presence of "driver-class" tag.
I hope it will help.
(Deploying mysql driver as a deployment also works and it's recommended way. https://docs.jboss.org/author/display/WFLY8/DataSource+configuration )
[edit]
I have mysql module under wildfly/modules/com/mysql/jdbc/main/ . I've noticed just now you module path doesn't correspond to module name. And I haven't find any doc's just yet, but I don't think you should mess with modules/system directory.
module.xml
<?xml version="1.0" ?>
<module xmlns="urn:jboss:module:1.1" name="com.mysql.jdbc">
<resources>
<resource-root path="mysql-connector-java-5.1.31-bin.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
</dependencies>
</module>
Two things: I just got mine working, and have the driver and xml located in $JBOSS_HOME/modules/com/mysql/jdbc/main - I'm fairly new with this as well so I'm not sure if that matters. Another thing: I don't know if it is just a typo, but if it was just copied and pasted it looks like your JAR name is incorrect
<resource-root path="mysql-connector-java-5.0.8.jar"/>
when it should be
<resource-root path="mysql-connector-java-5.0.8-bin.jar"/>
I forgot the .jar in mine, and that ended up fixing it. Hope that helps!
This may happen when you download the mysql connector zip and uploading the zip as a deployment. But the correct way is to unzip your download and point to the contained jar.
There are three ways using which you can simply create datasource into wildfly
Using admin console
Manually adding into standalone.xml
Creating datasource file that is xml file.
Go to WildFly directory/standalone/deployments
Simplest way to create datasource xml with following content
<datasources xmlns="http://www.jboss.org/ironjacamar/schema">
<datasource jndi-name="APP_DS" pool-name="APP_DS" enabled="true" use-ccm="false">
<connection-url>jdbc:mysql://localhost:3306/DB_NAME</connection-url>
<driver-class>com.mysql.jdbc.Driver</driver-class>
<driver>mysql</driver>
<!-- sql to call when connection is created -->
<new-connection-sql>SELECT 1</new-connection-sql>
<pool>
<min-pool-size>5</min-pool-size>
<max-pool-size>50</max-pool-size>
</pool>
<security>
<user-name>username</user-name>
<password>password</password>
</security>
<!-- sql to call on an existing pooled connection when it is obtained from pool -->
<validation>
<check-valid-connection-sql>SELECT 1</check-valid-connection-sql>
</validation>
<timeout>
<blocking-timeout-millis>300000</blocking-timeout-millis>
<idle-timeout-minutes>5</idle-timeout-minutes>
</timeout>
<statement>
<track-statements>true</track-statements>
</statement>
</datasource>
</datasources>

Using Mule Studio to read CSV

i try this example : Using Mule Studio to read CSV step by step but but content of csv donot copy to database . i have not any errors i left my console and myflow :
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:file="http://www.mulesoft.org/schema/mule/file" xmlns:jdbc="http://www.mulesoft.org/schema/mule/jdbc" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:spring="http://www.springframework.org/schema/beans" version="CE-3.3.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="
http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd
http://www.mulesoft.org/schema/mule/jdbc http://www.mulesoft.org/schema/mule/jdbc/current/mule-jdbc.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd ">
<configuration doc:name="Configuration">
<expression-language autoResolveVariables="true">
<import class="org.mule.util.StringUtils" />
</expression-language>
</configuration>
<jdbc:mysql-data-source name="MySQL_Data_Source" user="roor" url="jdbc:mysql://localhost:3306/csv" transactionIsolation="UNSPECIFIED" doc:name="MySQL Data Source" password="1234"/>
<jdbc:connector name="Database" dataSource-ref="MySQL_Data_Source" validateConnections="true" queryTimeout="-1" pollingFrequency="0" doc:name="Database">
<jdbc:query key="InsertRecord" value="INSERT INTO "tblFamily"("Title", "FirstName", "LastName") VALUES (#[message.payload[0]],#[message.payload[1]],#[message.payload[2]])"/>
</jdbc:connector>
<flow name="csvFlow1" doc:name="csvFlow1">
<!-- Step 1: CSV file source -->
<file:inbound-endpoint path="C:\Users\masoudy\Downloads\Compressed\Resoes" pollingFrequency="5000" doc:name="Source"/>
<!-- Step 2: Convert between object arrays and strings -->
<object-to-string-transformer doc:name="Object to String"/>
<splitter expression="#[StringUtils.split(message.payload, '\n\r')]" doc:name="Splitter"/>
<expression-transformer expression="#[StringUtils.split(message.payload, ',')]" doc:name="Expression"/>
<jdbc:outbound-endpoint exchange-pattern="one-way" queryTimeout="-1" doc:name="Destination" connector-ref="Database" queryKey="InsertRecord"/>
</flow>
</mule>
my console:
.....
**********************************************************************
* Application: csv *
* OS encoding: Cp1256, Mule encoding: UTF-8 *
* *
* Agents Running: *
* JMX Agent *
**********************************************************************
INFO 2013-04-22 14:55:54,437 [main] org.mule.module.launcher.DeploymentService:
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ Started app 'csv' +
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
console
csv
I could take good result and csv file converted to database.
I had 2 mistakes:
after run program, .csv file cleaned from path and I did not and run the program again without .csv file
name of fields in queries xml was difference to name of columns in database

Having connection issue Hibernate 3.0 with MySQL

I am getting this error. I have my hibernate connections and MVC all setup correct I believe.
I heard MySQL drivers have an issue for database connection.
SEVERE: Servlet.service() for servlet [appServlet] in context with path [/AdministrativeApplication] threw exception [Request processing failed; nested exception is org.springframework.transaction.CannotCreateTransactionException: Could not open Hibernate Session for transaction; nested exception is org.hibernate.exception.GenericJDBCException: Cannot open connection] with root cause
java.sql.SQLException: Unknown database 'testDB'
My hibernate configuration file
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
">
<!-- Load Hibernate related configuration -->
<tx:annotation-driven transaction-manager="transactionManager" />
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver"/>
<property name="url" value="jdbc:mysql://localhost:3306/testDB" />
<property name="username" value="myroot"/>
<property name="password" value="*****"/>
<!-- connection pooling details -->
<property name="initialSize" value="1"/>
<property name="maxActive" value="5"/>
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="hibernateProperties">
<!-- Declare a transaction manager-->
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQL5InnoDBDialect</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.hbm2ddl.auto">update</prop>
</props>
</property>
<property name="annotatedClasses">
<list>
<!-- all the annotation entity classes -->
</list>
</property>
</bean>
<!-- Declare a transaction manager-->
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"
p:sessionFactory-ref="sessionFactory" />
</beans>
Please let me know what
I could do to resolve this error.
I further added a new java file to test
import java.sql.*;
public class Connect
{
public static void main (String[] args)
{
Connection conn = null;
try
{
String userName = "root";
String password = "******";
String url = "jdbc:mysql://localhost:3306/testDB";
Class.forName ("com.mysql.jdbc.Driver").newInstance ();
conn = DriverManager.getConnection (url, userName, password);
System.out.println ("Database connection established");
}
catch (Exception e)
{
e.printStackTrace(System.out);
System.err.println ("Cannot connect to database server");
}
finally
{
if (conn != null)
{
try
{
conn.close ();
System.out.println ("Database connection terminated");
}
catch (Exception e) { /* ignore close errors */ }
}
}
}
}
I get this error . Also I started the MySQL console with this command.
"C:\Program Files\MySQL\MySQL Server 5.5\bin\mysqld.exe"
I get this error
java.sql.SQLException: Unknown database 'testdb'
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2975)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:798)
at com.mysql.jdbc.MysqlIO.secureAuth411(MysqlIO.java:3700)
at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1203)
at com.mysql.jdbc.Connection.createNewIO(Connection.java:2572)
at com.mysql.jdbc.Connection.<init>(Connection.java:1485)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:266)
at java.sql.DriverManager.getConnection(DriverManager.java:582)
at java.sql.DriverManager.getConnection(DriverManager.java:185)
at Connect.main(Connect.java:15)
Cannot connect to database server
Can some please help resolve this.
i ran netstats no luck. I do not see at what port MySQL is listening at.
Thanks again .
Dhiren
I am getting this error.
This means you did something wrong.
I have my hibernate connections and MVC all setup correct I believe.
See my previous comment - you did not do everything correctly.
I heard MySQL drivers have an issue for database connection.
Nope - MySQL drivers work fine if you set them up properly. You're doing something wrong, and you'll make progress faster if you take that attitude.
Before you run Java, start up the MySQL client, log into MySQL. If you can't, Java won't be able to, either. See if the daemon is up and running.
See if you have that database available. If not, create it.
If it is created, make sure that you have the tables you need and the user you're logging in as has appropriate permissions.
You could create a database named "testDB" in your MySQL instance.