java - JDBC MySQL; is supplying the DB name & username/password enough? -
When setting up a JDBC connection in J2EE application, do you need to specify the schema name in addition to the database name ?
I have followed and set up a database, and username / password, but when I am launching my application, I am coming against this error. Is it possible that DBUnet is trying to put data before it started in Hibernation and made schema? Reason: by org.dbunit.dataset.NoSuchTableException: The table 'Customer' did not find the schema 'empty'
My connection details are as follows:
& lt; Bean id = "dataSource" class = "org.apache.commons.dbcp .BasicDataSource" destroy-method = "close" & gt; & Lt; Property Name = "driverClassName" value = "com.mysql.jdbc.Driver" /> & Lt; Property Name = "url" value = "jdbc: mysql: //127.0.0.1: 3306 / Salestreaker" /> & Lt; Property Name = "User Name" Value = "Salestreaker" /> & Lt; Property Name = "Password" Value = "Salestreaker" /> & Lt; / Bean & gt;
I created the database:
[james @ nevada sales-tracker] $ mysql -u root -p enter password: Welcome to MySQL Monitor is . Finished with order; Or your MySQL connection ID is 16 server version: 5.1.42 Source distribution type 'help;' Or '\ c' to clear the current input statement for help, type '\ c' mysql & gt; show statistics; + -------------------- + + | Database | + -------------------- + + | Information_schema | | Mysql | | Celestrator | | Test | + -------------------- + 4 lines set (0.00 seconds)
Do I need to specify something in my hibernate Is Persistence.xml which asks to "use" a particular database? I was thinking that it will be contained in JDBC URL
Connect from database to root and ' Play 'Client' to see if there is a table (or 'show table'). If he is not getting it, then hibernation is not to be made automatically. If he finds it, then try to add it as a successor and see if that user does not have the proper permission, doing so with the same, if the table is in fact, then for the next step a simple You must write a Java program that connects and queries the table, that means remove the hibernate from the equation. Something like this:
class. ForName ("com.mysql.jdbc.Driver"); Connection Conn = DriverManager.getConnection ("jdbc: mysql: //127.0.0.1: 3306 / Celestrecker", "Salstrecker", "Salstrecker"); Prepared state s = conn.prepareStatement (select "count (*) from customer"); Results set rs = s.executeQuery (); Rs.next (); Println (rs.getString (1));
Comments
Post a Comment