Hi tomcat experts,
I'm having this problem with the mysql connection in tomcat using netbeans.
I'm always having a exclamation mark on the Blue World Globe in netbeans
project tabs. Everytime I try to resolve the data source problem using "New
Connection Wizard" in netbeans, the database textfield is always mysql. I
change it to abc_admin and press test connection button , it managed to
connect. When I press the finished button I always get " Unable to add
connection. Connection already exist "
Web.xml :
========
<resource-ref>
<description>GRANT SELECT, INSERT, DELETE, UPDATE ON abc_admin.*
TO 'all_100'@'localhost' IDENTIFIED BY 'gpwd_admin'</description>
<res-ref-name>jdbc/my_admin</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
Context.xml
==========
<Resource name="jdbc/my_admin" auth="Container"
type="javax.sql.DataSource"
maxActive="20"
maxIdle="30"
maxWait="10000"
username="all_100"
password="gpwd_abc_admin"
driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/abc_admin?autoReconnect=true"
/>
MYSQL Create Users
=================
"CREATE USER 'all_100'@'localhost' IDENTIFIED BY 'pwd_abc_admin'",
"FLUSH PRIVILEGES",
"GRANT SELECT, INSERT, DELETE, UPDATE ON abc_admin.* TO
'all_100'@'localhost' IDENTIFIED BY 'gpwd_abc_admin'",
"FLUSH PRIVILEGES",
Java Code to get the connection
=======================
protected Connection getCardDatabaseConnection(String ConnectionType)
throws NamingException, SQLException {
Connection connection = null;
DataSource dataSource;
InitialContext initialContext;
initialContext = new InitialContext();
dataSource = (DataSource) initialContext.lookup("java:comp/env/" +
"jdbc/my_admin");
connection = dataSource.getConnection();
return connection;
}