JDBC connects to MySQL installed with xampp

Problems with the Windows version of XAMPP, questions, comments, and anything related.

JDBC connects to MySQL installed with xampp

Postby camlg » 23. September 2005 20:55

My JDBC code worked with MySQL installed before I intalled xampp. Then, I uninstalled MySQL and intalled xampp with MySQL, and I tried to use my JDBC code, it couldn't connect to MySQL. Does anyone have an idea? Thanks!
:D
camlg
 
Posts: 3
Joined: 23. September 2005 20:42

Postby Wiedmann » 23. September 2005 21:13

and I tried to use my JDBC code, it couldn't connect to MySQL.

Without an error message we can not help you.
Wiedmann
AF Moderator
 
Posts: 17106
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Postby camlg » 23. September 2005 21:25

Sorry about this, error as below:

java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)
camlg
 
Posts: 3
Joined: 23. September 2005 20:42

Postby camlg » 23. September 2005 21:44

I have solved this problem... :oops:
Thanks.
camlg
 
Posts: 3
Joined: 23. September 2005 20:42

Re: JDBC connects to MySQL installed with xampp

Postby gyang » 29. January 2009 08:48

I have the same problem now. Do you mind telling us how you solved the problem. I noticed this thread is very old. Hope I can get some answers here. THanks.
gyang
 
Posts: 3
Joined: 29. January 2009 08:45

Re: JDBC connects to MySQL installed with xampp

Postby Izzy » 29. January 2009 08:55

Another example of why it is important to always return to the topic with the solution so it helps other members and guests searching the forums with a similar issue.

I think the chances of the OP returning a very slim.


Now lets recap the issue:
What is your exact error message?

What are you doing exactly?

Is the error from the Apache error.log file or where?

As much detail as possible will help with the troubleshoot, remember we can't know what you see or do and rely on you relaying that information.


BTW there is a MySQL Forum for JDBC and Java here which may be able to help with your JDBC issue.
Last edited by Izzy on 29. January 2009 09:32, edited 1 time in total.
Izzy
 
Posts: 3344
Joined: 25. April 2006 17:06

Re: JDBC connects to MySQL installed with xampp

Postby gyang » 29. January 2009 09:32

thanks for the swift reply!

This is my database connection code:
String dbUrl = "jdbc:mysql://localhost/Scheduler";
Class.forName("com.mysql.jdbc.Driver").newInstance();
con = DriverManager.getConnection(dbUrl, "sharon","1234");

Somehow, the user name "sharon" and password "1234" doesn't seem to get through... I did create this user name and password by using phpAdmin. I also have database "Scheduler" set up:
http://localhost/phpmyadmin/index.php?d ... ee1f0b395b

I accessed my project by http://localhost:8080/meetingScheduler

I put "mysql-connector-java-5.1.6-bin.jar" to directory "C:\Program Files\Java\jdk1.6.0_07\jre\lib\ext" and also to "C:\xampp\tomcat\lib".

Here's the error message from Tomcat log window ( I tried individual Tomcat, also addon from http://www.apachefriends.org/en/xampp-windows.html, both have the same error message).

.........
*** SQLException caught ***
ErrorCode: 1045

SQLState: 28000

Message: Access denied for user ''@'localhost' (using password: NO)

java.sql.SQLException: Access denied for user ''@'localhost' (using password: NO
)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1055)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3491)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3423)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:910)
at com.mysql.jdbc.MysqlIO.secureAuth411(MysqlIO.java:3923)
at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1273)
at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2031)
at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:718)
at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:46)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)

at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Sou
rce)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:302)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java
:282)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at moreservlets.EventBean.getSchedule(EventBean.java:60)
at org.apache.jsp.jsp.myCalendar_005fpage_jsp._jspService(myCalendar_005
fpage_jsp.java:439)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper
.java:374)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:3
37)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
alve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
alve.java:175)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
ava:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
ava:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal
ve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.jav
a:286)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java
:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.proce
ss(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:44
7)
at java.lang.Thread.run(Unknown Source)
java.sql.SQLException: Access denied for user ''@'localhost' (using password: NO
)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1055)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3491)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3423)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:910)
at com.mysql.jdbc.MysqlIO.secureAuth411(MysqlIO.java:3923)
at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1273)
at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2031)
at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:718)
at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:46)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)

at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Sou
rce)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:302)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java
:282)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at moreservlets.ToDoBean.getToDoList(ToDoBean.java:85)
at org.apache.jsp.jsp.myCalendar_005fpage_jsp._jspService(myCalendar_005
fpage_jsp.java:440)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper
.java:374)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:3
37)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
alve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
alve.java:175)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
ava:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
ava:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal
ve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.jav
a:286)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java
:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.proce
ss(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:44
7)
at java.lang.Thread.run(Unknown Source)
gyang
 
Posts: 3
Joined: 29. January 2009 08:45

Re: JDBC connects to MySQL installed with xampp

Postby Izzy » 29. January 2009 09:36

See my edit above re the JDBC forum as you may get better help there.

Thanks for the detailed response and good luck with it.

Please post back if you find a solution.
Thanks.

BTW did you JkMount the folder for your app in the mod_jdk.conf file in the apache\conf\extra folder?
Izzy
 
Posts: 3344
Joined: 25. April 2006 17:06

Re: JDBC connects to MySQL installed with xampp

Postby glitzi85 » 29. January 2009 09:42

It looks like the username is not transmitted to MySQL. You could try it in this way (Example 21.1): http://dev.mysql.com/doc/refman/5.1/en/ ... basic.html

glitzi
User avatar
glitzi85
 
Posts: 1920
Joined: 05. March 2004 23:26
Location: Dahoim

Re: JDBC connects to MySQL installed with xampp

Postby gyang » 29. January 2009 21:36

thanks for your replies.
It turned out that I forgot to change the connection statement in other servlets, oops!

Nothing magic, just follow the standard JDBC procedures. One thing I have to point out is that I have to specify a user name and password(even it's none) in the connection statement:

something like this: DriverManager.getConnection("jdbc:mysql://localhost/Scheduler?" +"user=sharon&password=1234");

If I just use:
DriverManager.getConnection("jdbc:mysql://localhost/Scheduler");

Then I will get the access denied error. Hope this will help folks with the similar errors.
gyang
 
Posts: 3
Joined: 29. January 2009 08:45

Re: JDBC connects to MySQL installed with xampp

Postby Izzy » 29. January 2009 22:32

Thanks for posting back as it will help others who have similar issue to find their solution by a forum search.

Good luck and happy oopses! :)
Izzy
 
Posts: 3344
Joined: 25. April 2006 17:06


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 69 guests