• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Are Java sql prepared statements case sensitive for a database server that is not case sensitive ?

 
Ranch Hand
Posts: 339
7
Tomcat Server Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I know that Java is case sensitive. I am currently writing code with sql statements to be used on MS SQLserver. The server was set up with case insensitive data and SQLserver field names are not case sensitive. The standard with SQLserver in my company is to use camel case on the column names, i.e. LastStatementDate. In Postgresql I use only lower case and underlines for column names because Postgresql fields are case sensitive. I am setting up a new SQLserver database and it will be accessed by servlets.

My question is when a sql command is prepared for execution on an SQLserver would Java classes such as PreparedStatement: executeUpdate() throw an error if the cases on the column names were not correct even if the SQLserver would not care?

Second question is are there best practices for column names in databases that will be accessed by Java ?

TIA.



 
Rancher
Posts: 2759
32
Eclipse IDE Spring Tomcat Server
  • Likes 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If your database server is case insensitive for column names, then SQL queries that are fired from Java will be case insensitive too. Java simply gives the query to the JDBC driver which will most likely just pass it to the database. Note I think resultSet.get is case sensitive. So, if you give it a column label, it has to be correct case (I could be wrong though.. it's been a while)

As far as naming conventions for databases. Some people use camel case, some people use underscore seperator. Most Java apps use camelcase because if you are using ORM tool like Hibernate, it;s easier to manage. Some people like underscore seperator because some DB tools automatically make the columns upper case, and then the columns aren't readable. It really depends on what tools you are using.
 
If you are using a rototiller, you are doing it wrong. Even on this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic