0
votes

Thanks for all the help guy!

Machine and Background: OSX 10.5.8 32-bit. MySQL password is "" i.e. empty

Goal: I'm trying to use the Java Database Connector (JDBC) tutorials. I'm currently at this step.

Error: With the shell at the directory where I have the JDBC Tutorial, I enter sudo ant create-mysql-database and get the following error:

Buildfile: /Users/adam/Desktop/JDBCTutorial/build.xml

create-mysql-database:

BUILD FAILED /Users/adam/Desktop/JDBCTutorial/build.xml:73: java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1074) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4074) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4006) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:919) at com.mysql.jdbc.MysqlIO.proceedHandshakeWithPluggableAuthentication(MysqlIO.java:1694) at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1244) at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2397) at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2430) at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2215) at com.mysql.jdbc.ConnectionImpl.(ConnectionImpl.java:813) at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:395) at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:334) at org.apache.tools.ant.taskdefs.JDBCTask.getConnection(JDBCTask.java:370) at org.apache.tools.ant.taskdefs.SQLExec.getConnection(SQLExec.java:942) at org.apache.tools.ant.taskdefs.SQLExec.execute(SQLExec.java:614) at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291) at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:592) at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106) at org.apache.tools.ant.Task.perform(Task.java:348) at org.apache.tools.ant.Target.execute(Target.java:390) at org.apache.tools.ant.Target.performTasks(Target.java:411) at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1399) at org.apache.tools.ant.Project.executeTarget(Project.java:1368) at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41) at org.apache.tools.ant.Project.executeTargets(Project.java:1251) at org.apache.tools.ant.Main.runBuild(Main.java:809) at org.apache.tools.ant.Main.startAnt(Main.java:217) at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280) at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109)

Self-Rectification Efforts: I tried adding grant all on initdb.* to 'root'@'127.0.0.1' identified by ''to the end of the command per this. Same error. It seems to be denying access to ant to do stuff; maybe if I turned off the using password option to NO, it would work; I tried googling around for that but no luck

Thanks again!

2

2 Answers

0
votes

In the JDBC tutorial folder's build.xml file, search for the string "create-mysql-database"; the string labels a task defined in the .xml file. Identify the value for the "password" parameter in that block of text (easier when reading the text with highlighting programs such as Dashcode), and change it to something that works with the system's databases (in my case "").

Having found what the string was in "password" before editing, find that same string throughout the .xml file and replace it with the correct password

Lesson: Apparently ant takes the string you passed in when invoking it (i.e. the string after the string "ant"), and looks for it in the build.xml present in the directory at which you invoked the program. Don't have the wrong password...

0
votes

Me too got struck at same place with same error in JDBC tutorials, as per whearyou suggestion, I just added my original password "YES" (which I created while making MySQL setup) in properties/mysql-build-properties.xml at line no: 28 .

Then it worked...!