Pattern for connecting to different databases using JDBC

后端 未结 4 1247
北荒
北荒 2021-02-09 07:33

I\'m writing an application which has to be configurable to connect to Oracle, SQL Server and MySQL depending on client whim.

Up till now I\'d been planning on using the

4条回答
  •  渐次进展
    2021-02-09 08:26

    If you're careful (and you test), you can do this with straight JDBC and just vary the driver class and connection information. You definitely want to stay away from the JDBC-ODBC bridge as it's generally slow and unreliable. The bridge is more likely to behave differently across dbs than JDBC is.

    I think the DAO path is overkill if your requirements are as simple as listed.

    If you're doing a lot of inserts, you might want to investigate prepared statements and batched updates as they are far more efficient. This might end up being less portable - hard to say without testing.

提交回复
热议问题