Posts

Showing posts from November, 2017

Too Many PreparedStatement Placeholders in Oracle JDBC

Image
There are multiple causes of the ORA-01745 ("invalid host/bind variable name error") error when using an Oracle database. The Oracle 9i documentation on errors ORA-01500 through ORA-02098 provides more details regarding ORA-01745 . It states that the "Cause" is "A colon in a bind variable or INTO specification was followed by an inappropriate name, perhaps a reserved word." It also states that the "Action" is "Change the variable name and retry the operation." In the same Oracle 12g documentation , however, there is no description of "cause" or "action" for ORA-01745, presumably because there are multiple causes and multiple corresponding actions associated with this message. In this post, I will focus on one of the perhaps less obvious causes and the corresponding action for that cause. Some of the common causes for ORA-01745 that I will NOT be focusing on in this post include using an Oracle database reserved na...

Log Unexpected Switch Options

There are many things a Java developer can do to make his or her own life and the lives of others maintaining that code easier. In this post, I'm going to look at a very easy approach a developer can take to make things easier for everyone. The point of this post will likely seem obvious to everyone reading it, but I see this not done far more often than I would have expected. In short, developers should typically log the value they are switch -ing on when that value is not represented by any of the explicit case statements within that switch . Before moving to specifics, I will add a few caveats. There are times when it may not make sense to log the value being switch -ed on that was not explicitly matched to a case . Some of these are listed here. The value being switched on is sensitive and should not be logged for security reasons. The value being switched on has numerous cases in which no match is expected and so the developer doesn't want to log unnecessarily. A default...

Third Edition of Effective Java Coming Soon

With the significant changes that have been made to the Java programming language since Java 6 (for which the Second Edition of Effective Java was published), Java developers have frequently asked about a third edition of the well-known and often-cited Java book Effective Java . When the forthcoming 3rd Edition of Effective Java was announced, there was a rush to pre-order it; as of this writing, it's the #1 New Release in the Java Programming category (it's also #7 overall in Books|Computers and Technology|Programming|Languages and Tools|Java and #49 in Books|Textbooks|Computer Science|Programming Languages ). According to its Amazon page and its Pearson Store page , Effective Java , Third Edition, is expected to be released in late December of this year (December 19 advertised on Pearson page and December 29 advertised on Amazon.com page ). The third edition is anticipated to have significant new and updated content given the changes to the language with Java 7 , ...

Humble Book Bundle: Java - A Great Deal for Java Developers

The Humble Book Bundle: Java is presented by O'Reilly Media and is available for a little less than two weeks from publication of this post. Purchasers of the bundle can select which "level" of bundle they'd like to purchase. The smallest bundle requires a minimum payment of $1, the middle bundle requires a minimum payment of $8, and the largest bundle requires a minimum payment of $15 (all currencies expressed here in U.S. dollars). These bundles are of Java-oriented electronic books published by O'Reilly and include some impressive titles. Portions of the proceeds go to charity, the electronic books are DRM-free, and the electronic books are available in multiple formats ( PDF , EPUB , MOBI ). Tier 1 Bundle ($1 Minimum) The first tier bundle can be acquired for as little as one dollar and includes the five books Think Java , Java Generics and Collections , Java in a Nutshell, 6th Edition (covers Java 8), Java Pocket Guide, 4th Edition (covers Java 8 and 9...

Simple String Representation of Java Decimal Numbers without Scientific Notation

The primary types /objects used for decimal numbers in Java are float / Float , double / Double , and BigDecimal . Each of these has cases in which its "default" string representation is "computerized scientific notation." This post demonstrates some simple approaches to provide a string representation of the decimal number in these cases without scientific notation. Examples in this post will demonstrate the "default" scientific notation String representations of these Java numeric types using a range of numbers for each type that demonstrate approximately where the "default" representation for each type becomes scientific notation. The next three code listings show the code for constructing general ranges for float s, double s, and BigDecimal s. The full source code listing for these examples is available on GitHub . Constructing the Example Range of Floats /** * Writes floats in the provided format and in the * provided range to standard ...

Java Command-Line Interfaces (Part 30): Observations

This series on parsing command line arguments in Java has consisted of 29 posts published over four months and covering 28 distinct open source libraries available for parsing command line arguments in Java. This post collects some observations that can be made from the first 29 posts in this series and provides some general considerations to make when selecting one of the 28 libraries or deciding to roll one's own command-line argument parsing code. Although no one library will be the best fit for every situation, this post will also look at how some libraries may be a better fit than others for specific situations. The post will end with a subset of the original 28 libraries that may be the most generally appealing of the covered libraries based on some criteria covered in the post. General Observations There are several observations that can be made after looking at the 28 libraries covered in this series on parsing command line arguments in Java . For most Java developers in...