Verify correct edit for ms-access database access
I want to check if I can edit a cell in the database with a new object
An example of a method declaration:
something.isValid(Object newObject, row, column);
Examples:
- If the edit cell stores the number and I give it a String the method will return false ...
- If the editing cell needs to be different from every other record (unique) and the new object is the same as the other, the method will also return false ....
My main goal ... I want to test a whole line, and if everything is correct, I will edit the whole line.
Right now, the only way to know if I can actually edit something is to actually edit it and see if I get an error.
edit: // Interface DatabaseMetaData
is a good method. Is there a SQL command method?
**** edit: // I feel that the resultsmetmeta data is good enough. however, where is the isUnique()
Method? ** edit: // isSigned () does this? edit: // So I just check if! isSigned () and isWritable (). What about database column conditions? For example ... X must be more than 3 characters ... **
a source to share
Don't use Object
, just use the type associated with the given data type. You can find more details here about what types of Java objects you should use for some DB data types with among others in this table:
(source: oracle.com )
Alternatively, you can use to get information about a column (column name, datatype, size, max length, nullable value, etc.). DatabaseMetaData#getColumns()
There are many other methods that can be , for example, for all indices, for determining PK, for determining FK, and so on. Just experiment throughout the API to find what you need. getIndexInfo()
getIndexInfo()
getIndexInfo()
getPrimaryKeys()
getExportedKeys()
DatabaseMetaData
a source to share