You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Lau Eng Huat <to...@gmail.com> on 2011/12/29 06:45:35 UTC
Database Connection Neteban DataSource
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;
}
Re: Database Connection Neteban DataSource
Posted by Pid <pi...@pidster.com>.
On 29/12/2011 05:45, Lau Eng Huat wrote:
> 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.
I don't know what that means.
> Everytime I try to resolve the data source problem using "New
> Connection Wizard" in netbeans, the database textfield is always mysql.
No idea about this either.
> 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 "
Are you having an issue with Netbeans rather than with Tomcat? If so,
you may find more help with that community.
p
> 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;
> }
>
--
[key:62590808]