Win a copy of Kubernetes in Action this week in the Cloud/Virtualization forum!

Avi Abrami

Ranch Hand
+ Follow
since Oct 11, 2000
Avi likes ...
Java Oracle
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
(keep public parts private until JForum day)
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt
Moderation Tools

Recent posts by Avi Abrami

After some more Google-ing, I discovered that this is a known problem.
In fact there is a bug about it.
FontMetrics.stringWidth() is slow if the String contains non-latin characters.
In my case the Strings contain Hebrew characters.
In my application, I retrieve about 500 Strings from a database and invoke FontMetrics.stringWidth() on each one - does that serve as a proper benchmark?
In any case, I believe my original question is still the issue and that is:

Why is FontMetrics.stringWidth() faster in jdk1.5.0_07?

In order to obtain an answer to that question, I guess I should compare the source code for the method in the different java versions.
So I will now Google for the source code - but if someone can point me in the right direction, I would appreciate it.

2 years ago
Perhaps the Performance forum was not the most appropriate?
Jeanne, I did not mention benchmarking. I asked if someone knows why there is a huge difference between the two JRE versions.
In any event the above code, in my application, runs only once anyway. The formatted String serves as an entry in a combo box list.
I calculate the greatest (String) width in order to determine the width of the combo box's dropdown list.

Campbell, for your information, our application does not run correctly using Java 7 - but that's another story.
And also for your information, I ran the above code - which is merely meant to serve as a SSCCI - under Java 7 and got the following results:

String.format() = 464975000
FontMetrics.stringWidth() = 23905617

In other words, jre1.7.0_79 is three times slower than jre1.5.0_22

2 years ago
Our application must use Java 5.
I noticed the performance of methods "String.format()" and "FontMetrics.stringWidth()" is much better in jre1.5.0_07 than in jre1.5.0_22
Perhaps someone can help me understand why?
Here is the code I used to test the methods:

Output I got when I ran the above code:
With jre1.5.0_07, I got ...
String.format() = 7021200
FontMetrics.stringWidth() = 2101975

With jre1.5.0_22, I got ...
String.format() = 154023576
FontMetrics.stringWidth() = 7462347

2 years ago
I live in Israel. I have a full-time job as a java software development engineer. I would like some advice and suggestions regarding finding extra work in the area of java software development.

2 years ago
OK, now I feel silly because I just found the answer:
Method 'setVerifyInputWhenFocusTarget' in class 'JComponent'.
So don't bother answering, people.
So is there a way to remove my question from the forum?

2 years ago
I have a Swing application that contains several JTextFields and JButtons.
The JTextFields have InputVerifiers which work correctly, i.e. you cannot navigate out of a
JTextField if invalid data is entered.
The application also has a "Exit" button, i.e. if the user activates that button, the
application terminates.
If I click on the "Exit" button immediately after entering invalid data in a JTextField,
the application doesn't terminate since the focus remains with the JTextField because of
the InputVerifier.
If the user wishes to terminate the application, then he should be allowed to even if he
has entered invalid data.
How can I achieve this? Is there a way to bypass the InputVerifier if the user activates
the "Exit" button?

2 years ago
A google search for the words: java exit code 13, and got _lots_ of results.
I didn't look into the individual results but I believe that with so many results, at least one will help you solve your problem.

Good Luck,
I don't think your Oracle JDBC driver is the latest version since Oracle 11.1 refers to Oracle 11g Release 1 and Oracle 11g Release 2 has been available for a long time now.
Indeed the latest Oracle database is 12c.
The Oracle Web site has a JDBC FAQ page which shows a compatibility matrix between Oracle database version, Oracle JDBC driver version and java version.
Make sure that in your enviornment everything matches.
In other words you need to find out which Oracle database you are using and which java version you are using and then get the suitable JDBC driver.

Good Luck,
Here is the scenario:
I have a java swing application.
1. The human user of my application asks it to fire up a scanner which
scans a paper document. The document is a filled in form.
2. The application then displays the scanned image to the human user.
The image is displayed in a JScrollPane since it may be larger than
the scroll pane.
3. The human user needs to locate a certain item in the form, for example
a social security number, and enter it into a field in a data entry
screen. Note that the image and the field appear on the same screen.

Of-course the social security number always appears in the same location
in the image.
Also the image needs to be the appropriate magnification and resolution
to allow the human user to easily read and understand the item he is
searching for in the image.

I would like someone to point me in the right direction as to the best
way to present the scanned image to the user such that he immediately
sees the item he requires and can enter it into the data entry field.
3 years ago
Thank you Jeanne.
As far as I can tell, the only relevant link on that page is HXTT.
However a $2651 (USD) Enterprise license price tag is not terrribly inviting.
By the way, I would suggest that someone update that page, especially the link to the JavaWorld article that was written 13 years ago and isn't relevant for Java 8.

Please refer to Oracle documentation for the database you are using.
There should be a book entitled "JDBC Developer's Guide".
In that book there should be a section entitled "Resultset Limitations and Downgrade Rules".
You should find there an explanation for the behaviour you describe.

Good Luck,
Your date string contains seconds.
Your format pattern does not.

Good Luck,
3 years ago
Prior to Java 8 it was possible to perform SQL queries on a Microsoft Excel file using the ODBC driver provided by Microsoft and the JDBC ODBC bridge driver which was part of the JDK.
Since the JDBC ODBC bridge driver is not part of JDK 8, how can I achieve the same functionality?
In other words I want to search for data in an Excel file in a similar way to querying it using SQL.

As stated, the database connection URL is incorrect.
Firstly, this part of the URL:
means you want to use the ODBC driver that handles "mdb" files.
However you refer to a "accdb" file since your filename in the URL is "ShoppingCart.accdb".
Also, you need to write the full path of your file, as indicated in the comment in the source code you posted that immediately precedes the declaration of local variable "url".
So the declaration of "url" should be something like...

Good Luck,
Pardon me for the extremely late reply, nonetheless, I suggest using java.sql.DatabaseMetaData to interrogate the data source you are connecting to in order to find the table names.
I leave you to peruse the javadoc for DatabaseMetaData.

Good Luck,