RE: JDBCAppender is not working for me.

Do I have to Modify the log4j.xml before using JDBCAppender.
I am getting error while using JDBCAppender.

================================
Error occur in Below statement:-

dataBaseAppender.setDriver(“com.mysql.jdbc.Driver”); // Drivers to use to connect to DB
console result:-

log4j:ERROR Failed to load driver
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at org.apache.log4j.jdbc.JDBCAppender.setDriver(JDBCAppender.java:391)
at Log4jSample.JDBCAppenderss.main(JDBCAppenderss.java:31)

================================
Can you please explain these lines more specifically:-

dataBaseAppender.setURL(“jdbc:mysql://localhost/test”); //Connection url
dataBaseAppender.setUser(“”); //Username for the DB connection
dataBaseAppender.setPassword(“”); //Password for the DB connection
dataBaseAppender.setDriver(“com.mysql.jdbc.Driver”); // Drivers to use to connect to DB

Means I have some dough like:-

1. What is “test” in jdbc:mysql://localhost/test
Is “test” name of a database, table or schema.
2. I do not have any username and password in mysql. So is it right to leave them as blank.
3. Most important :- com.mysql.jdbc.Driver??
Is it a default syntex or I have to modify it according to my IDE setup.

Your Support is highly appreciated in Advance!!!..

Thanks 🙂

shubham Train Asked on September 17, 2014 in Selenium WebDriver.
Add Comment
3 Answers

I have also not set any username and password for my MYSQL
I have also create a DB as name TEST in it.

Train Answered on September 18, 2014.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.