No suitable driver found (SQLite)

前端 未结 5 2038
夕颜
夕颜 2020-12-05 23:44

I hope someone can help me. I\'m working on a simple application which connects with an SQLite database. Following is my connection code:

try {           
           


        
5条回答
  •  执念已碎
    2020-12-06 00:12

    I was facing similar issues using a simple gradle configuration as follows

    apply plugin: 'java'
    
    repositories {
        mavenCentral()
    }
    
    dependencies {
        compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.0'
    
        testCompile group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: '5.2.0'
    
        compile group: 'org.xerial', name: 'sqlite-jdbc', version: '3.23.1'
    
    }
    
    jar {
        manifest {
            attributes 'Main-Class': 'rewards.simulator.MainSimulator'
    
        }
    }
    

    I later found that gradle build was creating a jar which was not including any external dependencies. Following configuration is to be used to include all your dependent libraries in the resulting jar file, along with your source files, to create a fat-jar:

    apply plugin: 'java'
    
    repositories {
        mavenCentral()
    }
    
    dependencies {
        compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.0'
    
        testCompile group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: '5.2.0'
    
        compile group: 'org.xerial', name: 'sqlite-jdbc', version: '3.23.1'
    
    }
    
    jar {
        manifest {
            attributes 'Main-Class': 'rewards.simulator.MainSimulator'
    
        }
        from {
            configurations.compile.collect { it.isDirectory() ? it : zipTree(it) }
        }
    }
    

提交回复
热议问题