• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
margaret gillon
Ranch Hand
Posts: 335
6
Linux Tomcat Server Ubuntu
  • Mark post as helpful
  • send pies
  • 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.



 
Jayesh A Lalwani
Rancher
Posts: 2762
32
Eclipse IDE Spring Tomcat Server
  • Likes 3
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic