This week's book giveaway is in the Programmer Certification forum.
We're giving away four copies of OCP Oracle Certified Professional Java SE 11 Programmer I Study Guide: Exam 1Z0-815 and have Jeanne Boyarsky & Scott Selikoff on-line!
See this thread for details.
Win a copy of OCP Oracle Certified Professional Java SE 11 Programmer I Study Guide: Exam 1Z0-815 this week in the Programmer Certification forum!

David Henstridge

Ranch Hand
+ Follow
since Mar 16, 2016
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
1
Received in last 30 days
0
Total given
1
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by David Henstridge

Well I will be the first to admit I don't know much about Java coding but I am one heck of a persistent SOAB!

I went back into the tables to study them, went back to the customization code and then went back into the program code itself.
I noticed that I had forgotten to add a couple of key parts:



The NCF in the second line and the  setInt(6, ticket.getTicketNCF());   in the fifth to last line.

I was sure this would fix the problem.
I built the project again and then ran it, adding a couple of sales.
Then I went into the Tickets table and sure enough the two new numbers had been added to the table that
held a bunch of <null> values above them.

Yippee!!  


2 years ago

David Henstridge wrote:
... Or to put it differently,
I know the TICKETS table had more than one column (STATUS) when this
Insert code was written.

It had all of the columns Except the NCF column.
Why re-insert columns it already had?



I wanted to edit my post but didn't see a way so I have to quote it now.
I now get that the guy is modifying the source code, so this INSERT is part of the actual
source.
But if it is, how can he neglect to add the STATUS column entirely?

2 years ago

Knute Snortum wrote:

Could this be the reason that NCF is not being updated?
Maybe the fact that there are now 7 columns instead of the expected 6?  


No.  That syntax for the INSERT uses the specific columns named to insert, not all of the columns from the table.





OK.
I am just trying to understand the setInt(6, ......) now.

That does not mean the sixth table value, but rather the sixth inserted value?
And if that is the case, why would the code written just insert six columns and not all seven?
That's another thing I'm confused about.

Or to put it differently,
I know the TICKETS table had more than one column (STATUS) when this
Insert code was written.

It had all of the columns Except the NCF column.
Why re-insert columns it already had?



2 years ago
I see the code added the following:



but when I look at the table TICKETS I see the following columns:

ID, TICKETTYPE, TICKETID, PERSON, CUSTOMER, STATUS, NCF

so my hunch is that in the ensuing years since the guy wrote the above add-on to the code
another column was added (STATUS).

Could this be the reason that NCF is not being updated?
Maybe the fact that there are now 7 columns instead of the expected 6?

If this is the case, what would I need to do to correct the problem?
2 years ago
As I continue to work with these two tables:
TICKETSNUM_NCF and TICKETS

I get more and more confused/frustrated.

The general instructions to modify the existing code was as follows:



Then we edit the "TICKETS" table to add a "NCF" column with integer type to it.



Neither of the above two worked out of the box, they had to be massaged a little,
but I kept the the names 'TICKETSNUM_NCF' (for the table) and
"NCF" for the column in table TICKETS.

Table 'TICKETSNUM_NCF' is working nicely with the code.
For each new sale, the ID column in the table increments by one.

Now here is the part that confuses me.
The TICKETS table had eleven entries in it when I added the new column called
'NCF'.

Default values of 'Null' were entered into the table for 'NCF'.
When I rang up some test sales, the NCF column in TICKETS continued to add 'Null'
values instead of the expected values which were being added to the
'TICKETSNUM_NCF' table ID column.

So one of my confusions is, why did the programmer name the column in TICKETS
NCF?
How is it linked to the only column in 'TICKETSNUM_NCF', column ID?

'TICKETSNUM_NCF' column ID updates correctly with sales but TICKETS
column NCF does not.

I hope someone gets this.  






2 years ago

David Henstridge wrote:
... So if you can tell me the correct syntax to Query this table and change it to
AUTOINCREMENT start 1 increment 1, like the other table, that would be great.

Or even better, please tell me the syntax to allow me change it to AUTOINCREMENT
and the start number to whatever I like?



The table I am talking about here is called Tickets.
I added a column called NCF but did not make it autoincrement at the time.

The suggested syntax to alter the table to add the column was:

ALTER TABLE `openbravopos`.`TICKETS` ADD `NCF` int(8)

I used a slightly different code but can't remember exactly what I used at the time.
I didn't mention the value because it is set now as 'Null'.



2 years ago

Dave Tolls wrote:A quick read of that page you linked to earlier and I would say this is something that POS software is supposed to handle?
It doesn't look to me like you are supposed to create an auto increment field of your own.
Of course, that's only based on a quick read.



Thanks for helping out Dave.

This POS is open source software and was designed from the start to evolve by users so-inclined
to improve/add to its functions.

The site that was linked to in my post shows code that was written by someone who did just that.
He was interested in adding a second receipt number, for tax purposes.
His country is the Dominican Republic.

I just so happen to have a business in the same country and want to also add a second receipt
number for the same reason.

2 years ago

Campbell Ritchie wrote:I have forgotten so much SQL, I think I had better duplicate you in the JDBC forum where we usually discuss such things.



OK thanks!
2 years ago

Campbell Ritchie wrote:A lot of database programs have a datatype called SERIAL or similar; that incorporates AUTOINCREMENT and is intended for primary keys, IDs, etc. Have you tried that? Note getting an int may cause difficulties because the SERIAL is probably an unsigned 64‑bit integer. It will probably behave like
(int)123456789101112L
It probably also implies NOT NULL.



Thanks for the info Campbell.
One reason I stuck with the resulting table the code created is because
it created the ID column with the same properties as three other closely
related table columns: AUTOINCREMENT start 1 increment 1, INTEGER, Is Nullable (NO) etc.
So everything looked good.

Speaking about looking good.....

I just checked a related Table that has a field for the NCF number.
This table is called Tickets and keeps detailed records of every sale.
I was surprised when I saw that the NCF column had <Null> for all test transactions
that I did yesterday. It should have had the same number that was being printed
on the tickets.

Then I looked at the Column_Def for the NCF. It said <null> !

So if you can tell me the correct syntax to Query this table and change it to
AUTOINCREMENT start 1 increment 1, like the other table, that would be great.

Or even better, please tell me the syntax to allow me change it to AUTOINCREMENT
and the start number to whatever I like?

TIA




2 years ago
I found a few more references to the label in the code:

2 years ago

Junilu Lacar wrote:That all depends on what you mean by "field name has not changed" and the code that's involved.

Are you referring to a database field or a field in an object? What code is involved in displaying this name that you say isn't changing? Show it to us so we have a better idea of what's going on.  



First off I must apologize for not getting my terminology straight.
I did not rename a field, but rather the field's label.

The only thing I see mentioned in the code for the label is:


Under the label's properties I see:
text:  RNC

This is the new name I gave the label.

What else would I have to change to get the new label to show?
The old label that still shows is Account ID.


2 years ago
I am currently having a problem renaming a field and wonder if someone might be able to help me with this problem?

I have opened the database in Netbeans IDE 8.1.
I found the field that needs to be renamed and renamed it.
Not only was the field on the current form reflecting the change, but another
form also showed the new name as well.

I re-built the .jar file and opened the app.
The field name had not changed in the app.

I went back and tried to clean and re-build the .jar file.
This time I got an error and could not clean/rebuild.

So I just chose rebuild once again.
I opened the app again, but once again the field name had not changed.

Any suggestions on this?
2 years ago

Campbell Ritchie wrote:Somebody has used the NON NULL command when creating that column in the database, so it throws an Exception if you try to insert NULL. You must put a real value in that column, and probably must not try to miss that column out when INSERT‑ing.



It was I who created the table and the column (ID).
I actually had created the column with a NULL command.

I had difficulty trying to find the right syntax to Alter the column from NULL to Increment by 1,
so finally I just bit the bullet, deleted the table and created a new one using the following syntax:

2 years ago
I somehow managed to get it to work!  
2 years ago

Campbell Ritchie wrote:I think we would need more details before we can help.
I am also suspicious about that website; it uses variable names which don't follow Java® naming conventions, and that makes me suspicious about the whole site I am afraid.



I am making very good progress on this.

I am now able to run the java program and have it bring up the main sales screen. All other screens function again as well.

There is one hiccup that I need to overcome now.
When I initiate a new sale, at the payment screen I get the following error:

NOT_00_0000
Notice: Unable to Save Sales Ticket

com.openbravo.basic.BasicException:
java.sql.SQLIntegrityConstraintViolationException: Column 'ID'  cannot accept a NULL value.

java.sql.SQLIntegrityConstraintViolationException:
Column 'ID'  cannot accept a NULL value.

org.apache.derby.impl.jdbc.EmbedSQLException:
Column 'ID'  cannot accept a NULL value.

org.apache.derby.iapi.error.StandardException:
Column 'ID'  cannot accept a NULL value.


If I can figure out which ID column they are talking about, I think I can nail this one.






2 years ago