Karel Young

Greenhorn
+ Follow
since Mar 02, 2004
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Karel Young

I added a null Check
if (!(rs==null)){...
To my code and that has gotten around the problem
I am having a problem in that I am getting an error instead of an empty ResultSet
TestCode
//Open Database
cc.DBOpen();
//Create Table
cc.DBUpdate("create table tblCustomer1 (id numeric(5), name character(20), address1 character(20), address2 character(20), phone character(20), email character(20), Loyalty_points numeric(5), primary key(id))");
//Close Database to Commit Changes
cc.DBClose();

//Open Database
cc.DBOpen();
//Run Query;
java.sql.ResultSet rs = cc.DBQuery("Select * from tblCustomer1");
//Close Database
cc.DBClose();
/*This Command Crashes
*Errorjava.lang.Exception: SELECT * FROM tblCustomer1
*There was an issue Retrieving all the Data from the Database:
*java.sql.SQLException: [unixODBC][MySQL][ODBC 3.51 Driver][mysqld-4.0.18-log]Table 'test.TBLCUSTOMER1' doesn't exist
*instead of returning an empty Resultset
*/
:cc is the class doing the links to the Database but that side of it works fine:
Under Windows I do not get the error but Under Linux (MySQL) I do.
When I run the Query direct to MySQL I get "Empty Set (0.00 sec)"

Any help would be appreciated
What I am wondering tho is how to crate the record using insertRow() without adding the Autoinc Field in there, I get an error when I do.
If possible I want to avoid using strings to add the new record (that is what I am using at the moment and what I am trying to get away from)
What I want ot be able to do is add a new record without having to commit the data first, I can edit a series of record and then commit them as a batch later on and I want to be able to do this with adding new records as well. (Without using arrays or vectors as I consider them to be a kludge )
Thanks for your help
I have found that I can add a new Record to the Record set by using the InserRow() method but I am running into an interensting problem in that the Database has an AutoIncrement field as the ID and as a result I cannot write to that field without the program crashing.
But I also cannot not write to the field because it throws an error.
An unexpected exception has been detected in native code outside the VM.
Unexpected Signal : 11 occurred at PC=0x4CD89AE3
Function=(null)+0x4CD89AE3
Library=/usr/lib/odbc/libmyodbc.so
NOTE: We are unable to locate the function name symbol for the error
just occurred. Please refer to release documentation for possible
reason and solutions.

There is about 5 times that amount of error but the rest is a library trace.
Any ideas?
20 years ago
I have found that I can add a new Record to the Record set by using the InserRow() method but I am running into an interensting problem in that the Database has an AutoIncrement field as the ID and as a result I cannot write to that field without the program crashing.
But I also cannot not write to the field because it throws an error.
An unexpected exception has been detected in native code outside the VM.
Unexpected Signal : 11 occurred at PC=0x4CD89AE3
Function=(null)+0x4CD89AE3
Library=/usr/lib/odbc/libmyodbc.so
NOTE: We are unable to locate the function name symbol for the error
just occurred. Please refer to release documentation for possible
reason and solutions.

There is about 5 times that amount of error but the rest is a library trace.
Any ideas?
Looking around on the Sun WebSite (Which is hard as 50% odd is down) it looks like they are creating a CachedRowSet Class which extends RowSet which in turn extends Resultset and gives the result I am looking for.
But although there are indications that you get get a copy of it off the web site (with Registration) there is actually no links to the Class itself.
I am doing a lot of hunting around at the moment to see what I can find.
20 years ago
I am creating a Java program that accesses a Database and so Far I have had no problems, but I have just realised that I need a "Multi-connect" architecture in my database rather than a perminant connection to the DataBase.
I did some research and found that once I closed the Database Link my ResultSet (I am using this to hold the data rather than an Array/Vector) closed as well, after some hunting I found that I needed to change my PreparedStatement line to read
---
PreparedStatement pstmt = conn.prepareStatement("SELECT * FROM " + tbl, ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE, ResultSet.HOLD_CURSORS_OVER_COMMIT);
---
But when I try to run this command I get this Error
---
Exception in thread "main" java.lang.UnsupportedOperationException
at sun.jdbc.odbc.JdbcOdbcConnection.setHoldability(JdbcOdbcConnection.java:1698)

---

Apart from this my program is fully functional.
If anyone can give me an idea on why I am getting this result/How to fix it. then I would appreciate it.
(PS I want to avoid using Vectors or Arrays if I can as I have found that the Resultset is more efficient and can store more Data about the DB)
My System
Linux - Debian 3.0 - Kernel 2.4.25
Windows XP
mySQl
MS Access
Java 1.4.2_02
Does the System throw an Exception when you do that or not?
I think that there is also an onTermination routine that you may be able to call as well
20 years ago
I have thought about using Vectors but If possible I want to avoid using them for the DB implementation
I prefer the way the the ResultSet interface works and it also shortens some of the code by some quite large amounts
20 years ago
I am creating a Java program that accesses a Database and so Far I have had no problems, but I have just realised that I need a "Multi-connect" architecture in my database rather than a perminant connection to the DataBase.
I did some research and found that once I closed the Database Link my ResultSet (I am using this to hold the data rather than an Array/Vector) closed as well, after some hunting I found that I needed to change my PreparedStatement line to read
---
PreparedStatement pstmt = conn.prepareStatement("SELECT * FROM " + tbl, ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE, ResultSet.HOLD_CURSORS_OVER_COMMIT);
---
But when I try to run this command I get this Error
---
Exception in thread "main" java.lang.UnsupportedOperationException
at sun.jdbc.odbc.JdbcOdbcConnection.setHoldability(JdbcOdbcConnection.java:1698)
---

Apart from this my program is fully functional.
If anyone can give me an idea on why I am getting this result/How to fix it. then I would appreciate it.
My System
Linux - Debian 3.0 - Kernel 2.4.25
Windows XP
mySQl
MS Access
Java 1.4.2_02
20 years ago