| View previous topic :: View next topic |
| Author |
Message |
akrynski
Joined: 06 Oct 2010 Posts: 8 Location: Szczecin, Poland
|
Posted: Wed Oct 06, 2010 2:47 pm Post subject: nb6.9.1 & javafx composer & mySql help needed |
|
|
Hi,
I am fresh new to javaFx so my problem may be trivial
I have grid binded to some records in mySql table with help of jdbcdataSource.
Problem is how to delete some records from db?
I tried jdbcdataSource.remove("here_table_name", " column_name = {labelInGrid.text}"); but it throws exception:
Unknown column name 'here_right_name_from_labelInGrid.text' in where clause.
"table_name.column_name = ..." doesn't work too.
Is this wrong way?
How to add, remove, update, select records using jdbcdataSource component? |
|
| Back to top |
|
 |
Maros Sandor Posted via mailing list.
|
Posted: Thu Oct 14, 2010 12:10 pm Post subject: nb6.9.1 & javafx composer & mySql help needed |
|
|
Hi,
JDBC data source has methods that can insert, update and delete database
rows. To remove rows from a table, execute DbDataSource.remove() method.
Its signature is:
remove(table : String, whereClause : String)
executes this sql statement:
var sql = "DELETE FROM {table} WHERE {whereClause}";
The problem is probably in the WHERE clause, I would recommend printing
it out for verification, maybe also print out the resulting SQL statement.
HTH,
Maros
On 06.10.2010 04:48 PM, akrynski wrote:
| Quote: | Hi,
I am fresh new to javaFx so my problem may be trivial
I have grid binded to some records in mySql table with help of jdbcdataSource.
Problem is how to delete some records from db?
I tried jdbcdataSource.remove("here_table_name", " column_name = {labelInGrid.text}"); but it throws exception:
Unknown column name 'here_right_name_from_labelInGrid.text' in where clause.
"table_name.column_name = ..." doesn't work too.
Is this wrong way?
How to add, remove, update, select records using jdbcdataSource component?
|
|
|
| Back to top |
|
 |
akrynski
Joined: 06 Oct 2010 Posts: 8 Location: Szczecin, Poland
|
Posted: Thu Oct 14, 2010 1:26 pm Post subject: whole function |
|
|
Here it is what I exactly was doing:
| Code: |
function butDeleteKlientaActionAtklienci(): Void {
//TODO
try {
var rs = jdbcdataSource.getRecordSet();
jdbcdataSource.remove("pismak_users.client", "pismak_users.client.name = {rs.currentField({
nameValueLabel.text
})}");
//jdbcdataSource.execute("START TRANSACTION;DELETE FROM pismak_users.client WHERE client.name={nameValueLabel.text};COMMIT;"); no effect visible
//jdbcdataSource.execute("DELETE FROM pismak_users.client WHERE pismak_users.client.name={nameValueLabel.text}"); no effect visible
//jdbcdataSource.query = "DELETE FROM pismak_users.client WHERE pismak_users.client.name={nameValueLabel.text}"; no effect visible
jdbcdataSource.refresh();
} catch (e) {
label.text = e.getMessage(); } finally { label.text = "Record {nameValueLabel.text} deleted"; }
} |
After changing a fragment of code to
"pismak_users.client.name = {rs.currentField({
nameValueLabel.text
})}"
there is no error message anymore. BUT...
Label on 'finally' clause changes to i.e. "Record 'John Doe' deleted"
Display changes moving back to first record in db, but table stays intact.
If I click on Next button 'deleted' record comes back!
So I think I've tried everything possible.
Best regards |
|
| Back to top |
|
 |
Maros Sandor Posted via mailing list.
|
Posted: Thu Oct 14, 2010 2:54 pm Post subject: nb6.9.1 & javafx composer & mySql help needed |
|
|
So the record is not deleted in the database? If this is the case, you
should first find a DELETE statement that works for you in your
database, this is not a problem in javafx, it just feeds JDBC driver
with SQL statements.
Maros
On 14.10.2010 03:27 PM, akrynski wrote:
| Quote: | Here it is what I exactly was doing:
Code:
function butDeleteKlientaActionAtklienci(): Void {
//TODO
try {
var rs = jdbcdataSource.getRecordSet();
jdbcdataSource.remove("pismak_users.client", "pismak_users.client.name = {rs.currentField({
nameValueLabel.text
})}");
//jdbcdataSource.execute("START TRANSACTION;DELETE FROM pismak_users.client WHERE client.name={nameValueLabel.text};COMMIT;"); no effect visible
//jdbcdataSource.execute("DELETE FROM pismak_users.client WHERE pismak_users.client.name={nameValueLabel.text}"); no effect visible
//jdbcdataSource.query = "DELETE FROM pismak_users.client WHERE pismak_users.client.name={nameValueLabel.text}"; no effect visible
jdbcdataSource.refresh();
} catch (e) {
label.text = e.getMessage(); } finally { label.text = "Record {nameValueLabel.text} deleted"; }
}
Label on 'finally' clause changes to i.e. "Record 'John Doe' deleted"
Display changes moving back to first record in db, but table stays intact.
If I click on Next button 'deleted' record comes back!
So I think I've tried everything possible.
Best regards
------------------------
Andrzej Kryński
|
|
|
| Back to top |
|
 |
Tony Posted via mailing list.
|
Posted: Thu Oct 14, 2010 3:22 pm Post subject: nb6.9.1 & javafx composer & mySql help needed |
|
|
Its a long time since I played with JBDC, but isn't it necessary to flush
the connection after a delete to clear the cached records?
Tony
-----Original Message-----
From: akrynski [mailto:address-removed]
Sent: 14 October 2010 14:27
To: address-removed
Subject: [nbusers] nb6.9.1 & javafx composer & mySql help needed
Here it is what I exactly was doing:
Code:
function butDeleteKlientaActionAtklienci(): Void {
//TODO
try {
var rs = jdbcdataSource.getRecordSet();
jdbcdataSource.remove("pismak_users.client",
"pismak_users.client.name = {rs.currentField({
nameValueLabel.text
})}");
//jdbcdataSource.execute("START TRANSACTION;DELETE FROM pismak_users.client
WHERE client.name={nameValueLabel.text};COMMIT;"); no effect visible
//jdbcdataSource.execute("DELETE FROM pismak_users.client WHERE
pismak_users.client.name={nameValueLabel.text}"); no effect visible
//jdbcdataSource.query = "DELETE FROM pismak_users.client WHERE
pismak_users.client.name={nameValueLabel.text}"; no effect visible
jdbcdataSource.refresh();
} catch (e) {
label.text = e.getMessage(); } finally { label.text = "Record
{nameValueLabel.text} deleted"; }
}
Label on 'finally' clause changes to i.e. "Record 'John Doe' deleted"
Display changes moving back to first record in db, but table stays intact.
If I click on Next button 'deleted' record comes back!
So I think I've tried everything possible.
Best regards
------------------------
Andrzej Kryński |
|
| Back to top |
|
 |
akrynski
Joined: 06 Oct 2010 Posts: 8 Location: Szczecin, Poland
|
Posted: Fri Oct 15, 2010 9:12 am Post subject: Re: nb6.9.1 & javafx composer & mySql help needed |
|
|
| Maros Sandor wrote: |
should first find a DELETE statement that works for you in your
database, |
There is no statement that works  |
|
| Back to top |
|
 |
akrynski
Joined: 06 Oct 2010 Posts: 8 Location: Szczecin, Poland
|
Posted: Fri Oct 15, 2010 9:16 am Post subject: Re: nb6.9.1 & javafx composer & mySql help needed |
|
|
| Tony wrote: | but isn't it necessary to flush
the connection after a delete to clear the cached records?
|
I think refresh() method performs flush action  |
|
| Back to top |
|
 |
Maros Sandor Posted via mailing list.
|
Posted: Fri Oct 15, 2010 9:16 pm Post subject: nb6.9.1 & javafx composer & mySql help needed |
|
|
If there is no DELETE statement that works in your database then you are
discussing this issue in a wrong forum I guess.
Maros
On 15.10.2010 11:13 AM, akrynski wrote:
| Quote: |
Maros Sandor wrote:
| Quote: |
should first find a DELETE statement that works for you in your
database,
|
There is no statement that works [Evil or Very Mad]
------------------------
Andrzej Kryński
|
|
|
| Back to top |
|
 |
akrynski
Joined: 06 Oct 2010 Posts: 8 Location: Szczecin, Poland
|
Posted: Sun Oct 17, 2010 1:33 pm Post subject: Re: nb6.9.1 & javafx composer & mySql help needed |
|
|
| Maros Sandor wrote: | then you are
discussing this issue in a wrong forum I guess.
|
Then which one? If something works then is no purpose to ask for help  |
|
| Back to top |
|
 |
Bredie
Joined: 30 Aug 2010 Posts: 13
|
Posted: Mon Oct 18, 2010 1:35 pm Post subject: nb6.9.1 & javafx composer & mySql help needed |
|
|
akrynski wrote:
| Quote: | Maros Sandor wrote:
| Quote: | then you are
discussing this issue in a wrong forum I guess.
|
Then which one? If something works then is no purpose to ask for help :?
|
Try a Java-oriented newsgroup. Programming is programming regardless of
the IDE used. |
|
| Back to top |
|
 |
Maros Sandor Posted via mailing list.
|
Posted: Mon Oct 18, 2010 9:57 pm Post subject: nb6.9.1 & javafx composer & mySql help needed |
|
|
http://forums.mysql.com/
On 17.10.2010 03:33 PM, akrynski wrote:
| Quote: |
Maros Sandor wrote:
| Quote: | then you are
discussing this issue in a wrong forum I guess.
|
Then which one? If something works then is no purpose to ask for help :?
------------------------
Andrzej Kryński
|
|
|
| Back to top |
|
 |
|