I want to be able to check if I can edit a cell in a database with a new object
Example method declaration:
something.isValid(Object newObject, row, column);
Example cases:
My main goal... I want to check a whole row, and if everything is valid, I will edit the whole row.
Right now, the only way I can find out if I can actually edit something is by actually editing it and seeing if I get an error.
edit://Interface DatabaseMetaData
is a good method. Is there a SQL command method?
****edit://I feel like the resultsetmeta data is good enough. however, where is the isUnique()
Method?** edit://isSigned() accomplishes this?
edit://So I just check if !isSigned() and isWritable(). What about database column conditions? For example... X has to be more than 3 characters...**
Don't use Object
, but just use the type which is associated with the datatype in question. You can find here more detailed information about which Java object types you should be using for certain DB datatypes with among others this table:
(source: oracle.com)
Alternatively, you can use DatabaseMetaData#getColumns()
to figure the column information (column name, datatype, size, maxlength, nullable, etc).
There are lot of other methods which may be of use, e.g. getIndexInfo()
to figure all indexes, the getPrimaryKeys()
to figure the PK's, the getExportedKeys()
to figure the FK's, etcetera. Just poke a bit round in the whole DatabaseMetaData
API to find that you need.