Loading JDBC Driver at Runtime

前端 未结 3 1244
伪装坚强ぢ
伪装坚强ぢ 2021-01-19 05:37

I\'m using the following code to load a driver class:

public class DriverLoader extends URLClassLoader {

    private DriverLoader(URL[] urls) {
        supe         


        
3条回答
  •  滥情空心
    2021-01-19 06:15

    You need to add a Classpath reference in the manifest. Follow these simple steps:

    add a folder "lib" to your application

    place "mysql-connector-java-5.1.18-bin" in lib

    now open your "MANIFEST.MF" and go to tab "RUNTIME"

    on bottom right, you would see "classpath" ; click "Add"

    now add the folder lib [created in step 1] along with the jar file

    in this way, whenever a runtime EclipseApplication /OSGi Application is started this jar file is exported along too. So the connectivity would then be available there too.

提交回复
热议问题