Everywhere else in Java, anything with an index starts at 0. Is there a reason for the change here or is this just bad design?
It starts with 1 , as all the indexes in database related statements start with 1.
A prepared statement is a server-side object that can be used to optimize performance. When the PREPARE statement is executed, the specified statement is parsed, analyzed, and rewritten. When an EXECUTE command is subsequently issued, the prepared statement is planned and executed.
Historically, databases have used 1-based indexing for bound parameters. This probably reflects the origins of relational databases in set theory and mathematics, which index elements starting with one, and use zero to represent a null or empty set.
In shell scripts and regular expressions, the zero index usually means something "special". For example, in the case of shell scripts, the zeroth "argument" is actually the command that was invoked.
The choice for JDBC was deliberate but, ultimately, probably causes more confusion and difficulty than it solves.
This was part of a plot by the original language designers to weed out the weak. In the original spec, arrays were numbered from -1, and lists with 1 element returned length =0.
Today, only the java Calendar API remains from this diabolical plot.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With