NetBeans Forums

 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
  

nb6.9.1 & javafx composer & mySql help needed

 
Post new topic   Reply to topic    NetBeans Forums -> NetBeans Users
View previous topic :: View next topic  
Author Message
akrynski



Joined: 06 Oct 2010
Posts: 8
Location: Szczecin, Poland

PostPosted: Wed Oct 06, 2010 2:47 pm    Post subject: nb6.9.1 & javafx composer & mySql help needed Reply with quote

Hi,
I am fresh new to javaFx so my problem may be trivial Wink
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.





PostPosted: Thu Oct 14, 2010 12:10 pm    Post subject: nb6.9.1 & javafx composer & mySql help needed Reply with quote

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 Wink
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

PostPosted: Thu Oct 14, 2010 1:26 pm    Post subject: whole function Reply with 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"; }
   
     }

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"Laughing
Display changes moving back to first record in db, but table stays intact. Shocked
If I click on Next button 'deleted' record comes back!Mad
So I think I've tried everything possible.

Best regards
Back to top
Maros Sandor
Posted via mailing list.





PostPosted: Thu Oct 14, 2010 2:54 pm    Post subject: nb6.9.1 & javafx composer & mySql help needed Reply with quote

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.





PostPosted: Thu Oct 14, 2010 3:22 pm    Post subject: nb6.9.1 & javafx composer & mySql help needed Reply with quote

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

PostPosted: Fri Oct 15, 2010 9:12 am    Post subject: Re: nb6.9.1 & javafx composer & mySql help needed Reply with quote

Maros Sandor wrote:

should first find a DELETE statement that works for you in your
database,


There is no statement that works Evil or Very Mad
Back to top
akrynski



Joined: 06 Oct 2010
Posts: 8
Location: Szczecin, Poland

PostPosted: Fri Oct 15, 2010 9:16 am    Post subject: Re: nb6.9.1 & javafx composer & mySql help needed Reply with quote

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 Question
Back to top
Maros Sandor
Posted via mailing list.





PostPosted: Fri Oct 15, 2010 9:16 pm    Post subject: nb6.9.1 & javafx composer & mySql help needed Reply with quote

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

PostPosted: Sun Oct 17, 2010 1:33 pm    Post subject: Re: nb6.9.1 & javafx composer & mySql help needed Reply with quote

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 Confused
Back to top
Bredie



Joined: 30 Aug 2010
Posts: 13

PostPosted: Mon Oct 18, 2010 1:35 pm    Post subject: nb6.9.1 & javafx composer & mySql help needed Reply with quote

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.





PostPosted: Mon Oct 18, 2010 9:57 pm    Post subject: nb6.9.1 & javafx composer & mySql help needed Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    NetBeans Forums -> NetBeans Users All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB
By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo