• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Its Very Urgent !!!! Help Me Now !!!!!!

 
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ello,
Can anybody help me, I am in a great toruble, Here in this example the comment part i.e.(//) this part they have mentioned that due to absence of database schema..the everything is locked. I want to know that how to open a lock so that I can able to edit the contents of the Cell. Please help me, what all changes I have to make to open a lock. For more reference: This is a Table Example of JDK1.3. or higher. I had taken out this code from:
D:\j2sdk1.4.0\demo\jfc\TableExample\src
The files are:
1) JDBCAdapter (For database connectivity)
2) TableMap (Defines underlying data structure of JTable)
3) TableSorter (For sorting)
5) Table Example (Main Class)
public void setValueAt(Object value, int row, int column) {
try {
String tableName = metaData.getTableName(column+1);
// Some of the drivers seem buggy, tableName should not be null.
if (tableName == null) {
System.out.println("Table name returned null.");
}
String columnName = getColumnName(column);
String query =
"update "+tableName+
" set "+columnName+" = "+dbRepresentation(column, value)+
" where ";
// We don't have a model of the schema so we don't know the
// primary keys or which columns to lock on. To demonstrate
// that editing is possible, we'll just lock on everything.

for(int col = 0; col<getColumnCount(); col++) {
String colName = getColumnName(col);
if (colName.equals("")) {
continue;
}
if (col != 0) {
query = query + " and ";
}
query = query + colName +" = "+
dbRepresentation(col, getValueAt(row, col));
}
System.out.println(query);
System.out.println("Not sending update to database");
// statement.executeQuery(query);
}
catch (SQLException e) {
// e.printStackTrace();
System.err.println("Update failed");
}
Vector dataRow = (Vector)rows.elementAt(row);
dataRow.setElementAt(value, column);
}
}
I want to use this code in one of my project. Please help me, I will be really very thankful to you. And if you are having any of the source code through which my need can be fulfilled, please give it to me i will be really thankful to you. Actually my need is,
When I pass some ID to the database (SQL) it give results in JTable, and that results can be edited i.e. (Adding of rows, Deleting of rows, Changing values of Cells etc.) If anybody is having such kind of code or any weblink please let me know. It is a request to all java developers.

Thanks
Anu
 
Ranch Hand
Posts: 1879
MySQL Database Suse
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
a schema is not needed to get the primary keys from the connection. Have a look at the DatabaseMetaData's getPrimaryKeys() function.
from the java.sql.DatabaseMetaData docs:
getPrimaryKeys
Parameters:
catalog - a catalog name; "" retrieves those without a catalog; null means drop catalog name from the selection criteria
schema - a schema name; "" retrieves those without a schema
table - a table name

instead of specifying the Schema name, just use empty strings to indicate it does not have a schema
Jamie
[ April 21, 2003: Message edited by: Jamie Robertson ]
 
Anurag Mishra
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear Jamie Robertson,
Can you please tell me in detail, what i have to do to eliminate a lock from this code. Kindly write a line of code as an example for me, I will really help me a lot.
Anu
 
No matter how many women are assigned to the project, a pregnancy takes nine months. Much longer than this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic