Reputation: 221
I am a newbie and have some question on using jdbc with java:
What changes in the code I will have to make to:
Also - how to make queries cached?
Upvotes: 0
Views: 191
Reputation: 1108712
change database type? (i.e. from PostgreSQL na MySQL)
Replace the MySQL JDBC driver in the classpath with the PostgreSQL JDBC driver. Update the JDBC connection URL to point to PostgreSQL DB instead of MySQL DB. If necessary, also update your SQL queries to replace any MySQL-specific SQL functions/clauses by PostgreSQL-specific ones.
use the table in the code after I decide to drop one of the colums from that table.
Remove the column in question from the SQL queries. If necessary, also update the entity (the custom Javabean class which you have to represent one row of the DB) to remove the property and getter/setter.
Also - how to make queries cached?
Use PreparedStatement
instead of Statement
. If possible, replace all the JDBC code by a fullworthy ORM such as JPA or good ol' Hibernate. They not only minimizes JDBC boilerplate code to oneliners, but they also offers second-level caching capabilities as well.
Upvotes: 1