I'm running in process hsqldb in my java code for testing purposus, and i'm getting the following error:
user lacks privilege or object not found: MY_TEMP_TABLE
only when i debug the code. If i run the (junit) test without debug, everything is working.
I do need the debugger for some other areas.
I'm getting the error on this query:
INSERT INTO MY_TEMP_TABLE VALUES ('a','a','a')
I don't think the problem is in sql syntax because all queries are working when running the test without debug.
Any help would be appriciated..
Obviously your table is not present when you debug your code.
One possibility is the table is not created at all. To see what is happening, use the jdbc:hsqldb:file:yourdb as the database URL and check the yourdb.log file for the CREATE TABLE statements.
The other possibility is the table is not in the PUBLIC (or default) schema and you are not changing the schema to the one that contains the table.
Related
I was working on some program in Java and involving MySQL database. As we know, most programs need database to work with.
As I am thinking there could exceptions that could handles in the application, for example:
Failed to insert to db
table does not exist
etc
When I catch these kind of exceptions, I have the option to store this error message in a form of error code in my table under a Error column.
Now consider this, to establish a connection between an application and the database, I need the IP along with it's username and password before the program works.
In that case, if I were to "break" the program by giving a wrong password , or I easily terminate MySQL service while the application is running. If this happens, the application will throw some sort of database error connection since it couldn't connect to it. At the same time, I can't update the Error column of the table since no connection establish between the program and the db.
I can't seem to figure out the best way to handle this or if there is even a way to do so.
How would one handle this kind of scenario?
Approach#1
You can log these errors in a log file.
If you really want to add every error in the database, then later on you can fetch the errors by scraping the log file and insert them into the database.
Approach#2
You can either try to reconnect to the database & if successful, write the error to the database. If not able to connect then you can fallback to approach#1.
So I recently set up a database through Microsoft Azure using clearDB's MySQL db.
I connected to it through java with the given server, name and user credentials given to me, and everything worked fine, for eight hours... suddenly out of nowhere when I connected (without changing anything that actually had to do with the connection) I got the error message "Access denied for user 'my-given-username'#'%' to database 'my-db-name'"
I double checked everything, and even made a new program trying to connect, but same error message. On the Azure portal and clearDB page it says that the status of the DB is healthy, that it's absolutely not filled up (1.09 %) and that the number of connections is 0 out of maximum 4.
I made a new database the same way, changed the connecting settings accordingly and everything worked just fine!
Does anyone have any idea what might be wrong?
Even though everything is working now with the new DB, I'm afraid the same thing will happen to this one after a while.
Per my experience, the issue is normally related to MySQL user privileges.
I tried to test several sql query in Java to reproduce this issue on Azure ClearDB, and found these SQL cases below caused this issue.
Execute the sql CREATE DATABASE <new-db> in current database
Connect the Jdbc Url jdbc:mysql://<db-host>:3306/mysqlwith current database user & password
Execute the sql query after some grant operation, such as cancel select privilege on table
Although I don't know what sql query your Java program do caused this issue, I think these cases can help you checking.
Any concern, please feel free to let me know.
I have done a lot of internet searches, and can't find a report of a problem quite like this one, so I'm hoping someone here might have an idea of what is going wrong. In my java code I have a query that is pulling data from the database. I have confirmed that the SQL is well-formed, and all of my other queries in this java file run fine. In fact, even this query runs as it should when I am using the dev test Tomcat server. However, when I try to run this particular query using the dev test Resin server (where it was working perfectly fine up until just recently), or the QA test server, which also uses Tomcat, I get this error:
com.mysql.jdbc.MysqlDataTruncation: Data truncation: Incorrect datetime value: '131500'
The '131500' I'm assuming is coming from the time portion of the first datetime value that is returned, which is '13:15:00'.
The particular part of this query that is causing the problem is this line:
CONCAT(DATE_FORMAT((SELECT datenotime), '%Y-%m-%d'),' ',DATE_FORMAT((SELECT appointmenttime FROM appointments WHERE appointmentdate = datenotime AND appointments.service_id = service.id), '%T'))
If I remove this then I experience no problems on any server, so it only occurs when the time is formatted and concatenated. I would think that the issue here must be some server setting? Although there were no recent changes made to the Resin server that I know of. I tried updating Resin's msyql connector jar, but that didn't help. Does anyone know what is going wrong?
Thanks!
My guess is that you are getting this error when datenotime is null.
That would make sense, since you are concatenating datenotime and then appointmenttime. If datenotime is null, then all you have left is time, which simply can't be converted to any known datetime value.
I have a simple application that writes data from a MySQL database into an Access .accdb database.
I have used it for 4 months and I haven't had any problems.
Yesterday I tried to use it and now I have a problem. If I try to open the file with Microsoft Access and I try to open table CodScontrini, I see all the records. If I try to open Scontrini table I have this message:
bookmark not valid
If I try to run my Java application from Eclipse I see this warning message:
WARNING:Error in the metadata of the table CodScontrini: table's row count in the metadata is 665 but 499 records have been found and loaded by UCanAccess. All will work fine, but it's better to repair your database.
It means that a inconsistency between data and metadata has been detected in your access db. The Compact and Repair tool will solve this issue.
I have a Java program that needs to pull from a Microsoft Access database. I recently had to change the code to use UCanAccess instead of ODBC as the JDBC-ODBC Bridge is not supported in Java SE 8 (Manipulating an Access database from Java without ODBC)
When I run the code shown below (just the sample code given on the UCanAccess website), I get an error -
ERROR: net.ucanaccess.jdbc.UcanaccessSQLException: user lacks privilege or object not found: NULL
The code is as follows
Connection conn=DriverManager.getConnection("jdbc:ucanaccess://Z:\\Assignment.accdb");
Statement s = conn.createStatement();
ResultSet rs = s.executeQuery("SELECT * FROM tbl2014janjun"); //tbl2014janjun ORDER BY ID
while (rs.next()) {
System.out.println(rs.getString(1));
}
While testing, I noticed that a separate database, Work Order, is able to be accessed by this code and the output is as expected. In addition, whenever this code tries to run, it produces the locking laccdb file in the server directory. Because of this, I believe the issue lies with user privileges. While searching this site for possible answers, most of them related to the second half of the error message - the table was misspelled, etc. I have made sure that the spelling/location/file structure is correct.
Thank you for any help you can provide.
I had exactly the same issue after moving from Tomcat 6 to 7.
Two databases in the same place with the same tables and columns, just the data is different (different projects).
One worked fine, the other one gave the above-mentioned error.
Fixed it by doing a "Compact and Repair Database" operation from within the Access windows app. (In Access 2007 it's Manage > Repair from the main toolbar dropdown.)