英文:
Corda - postgres database driver (postgresql-42.2.8.jar) missing
问题
我正在使用 corda 4.5,其中 gradle插件版本为5.0.10,并且将postgres作为我的数据库。
当我尝试运行deployNodes
任务时,出现以下错误:
[ERROR] 15:51:47+0530 [main] internal.NodeStartupLogging. - 无法找到数据库驱动程序类。请将其添加到驱动程序目录中。[错误代码:database-missing-driver 欲了解更多信息,请访问https://docs.corda.net/docs/corda-os/4.5/error-codes.html] - 无法找到数据库驱动程序类。请将其添加到'drivers'文件夹中。[errorCode=1oswgkz, moreInformationAt=https://errors.corda.net/OS/4.5/1oswgkz]
以下是build.gradle
文件中deployNode
任务的代码:
task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) {
nodeDefaults {
projectCordapp {
deploy = false
}
cordapp "$confidential_id_release_group:ci-workflows:$confidential_id_release_version"
cordapp "$accounts_release_group:accounts-contracts:$accounts_release_version"
cordapp "$accounts_release_group:accounts-workflows:$accounts_release_version"
cordapp project(':cordapp-contracts-states')
cordapp project(':workflows')
//ext.drivers = ['${rootProject.projectDir}/lib/postgresql-42.2.8.jar']
}
// NOTARY NODE
node {
name "O=Notary,L=London,C=GB"
notary = [validating: true]
p2pAddress("localhost:10002")
rpcSettings {
address("localhost:10003")
adminAddress("localhost:10043")
}
}
// NODEA
node {
name "O=NODEA,L=Lucknow,C=IN"
p2pAddress("localhost:10010")
rpcSettings {
address("localhost:10011")
adminAddress("localhost:10052")
}
rpcUsers = [[user: "userA", "password": "user123", "permissions": ["ALL"]]]
//new DB config
//DB
extraConfig = [
'dataSourceProperties.dataSource.url': 'jdbc:postgresql://localhost:5432/egdb?currentSchema=nodeA_schema',
'dataSourceProperties.dataSourceClassName': 'org.postgresql.ds.PGSimpleDataSource',
'dataSourceProperties.dataSource.user': 'postgres',
'dataSourceProperties.dataSource.password': 'postgres',
//'dataSourceProperties.driverClassName': 'org.postgresql.ds.PGSimpleDataSource'
//'jarDirs': ['${rootProject.projectDir}/lib/postgresql-42.2.8.jar']
//'drivers': 'org.postgresql.Driver'
'jarDirs': ['${rootProject.projectDir}/lib/jdbc/driver/postgresql-42.2.8.jar']
]
//jarDirs = ['${rootProject.projectDir}/lib/postgresql-42.2.8.jar']
//drivers = ext.drivers
}
// NODEB
node {
name "O=NODEB,L=Delhi,C=IN"
p2pAddress("localhost:10010")
rpcSettings {
address("localhost:10011")
adminAddress("localhost:10052")
}
rpcUsers = [[user: "userB", "password": "user123", "permissions": ["ALL"]]]
//new DB config
//DB
extraConfig = [
'dataSourceProperties.dataSource.url': 'jdbc:postgresql://localhost:5432/egdb?currentSchema=nodeB_schema',
'dataSourceProperties.dataSourceClassName': 'org.postgresql.ds.PGSimpleDataSource',
'dataSourceProperties.dataSource.user': 'postgres',
'dataSourceProperties.dataSource.password': 'postgres',
//'dataSourceProperties.driverClassName': 'org.postgresql.ds.PGSimpleDataSource'
//'jarDirs': ['${rootProject.projectDir}/lib/postgresql-42.2.8.jar']
//'drivers': 'org.postgresql.Driver'
'jarDirs': ['${rootProject.projectDir}/lib/jdbc/driver/postgresql-42.2.8.jar']
]
//jarDirs = ['${rootProject.projectDir}/lib/postgresql-42.2.8.jar']
//drivers = ext.drivers
}
}
如何在build.gradle
文件中添加PostgreSQL JDBC驱动程序路径?Corda 4.5与兼容的PostgreSQL版本是多少?
英文:
I am using corda 4.5 with gradle plugin version as 5.0.10 and postgres as my DB.
when I am trying to run deployNodes task, getting below error:
[ERROR] 15:51:47+0530 [main] internal.NodeStartupLogging. - Could not find the database driver class. Please add it to the drivers directory. [Error Code: database-missing-driver For further information, please go to https://docs.corda.net/docs/corda-os/4.5/error-codes.html] - Could not find the database driver class. Please add it to the 'drivers' folder. [errorCode=1oswgkz, moreInformationAt=https://errors.corda.net/OS/4.5/1oswgkz]
Following is the deployNode task code in build.gradle file:
task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) {
nodeDefaults {
projectCordapp {
deploy = false
}
cordapp "$confidential_id_release_group:ci-workflows:$confidential_id_release_version"
cordapp "$accounts_release_group:accounts-contracts:$accounts_release_version"
cordapp "$accounts_release_group:accounts-workflows:$accounts_release_version"
cordapp project(':cordapp-contracts-states')
cordapp project(':workflows')
//ext.drivers = ['${rootProject.projectDir}/lib/postgresql-42.2.8.jar']
}
//NOTARY NODE
node {
name "O=Notary,L=London,C=GB"
notary = [validating: true]
p2pAddress("localhost:10002")
rpcSettings {
address("localhost:10003")
adminAddress("localhost:10043")
}
}
// NODEA
node {
name "O=NODEA,L=Lucknow,C=IN"
p2pAddress("localhost:10010")
rpcSettings {
address("localhost:10011")
adminAddress("localhost:10052")
}
rpcUsers = [[user: "userA", "password": "user123", "permissions": ["ALL"]]]
//new DB config
//DB
extraConfig = [
'dataSourceProperties.dataSource.url' : 'jdbc:postgresql://localhost:5432/egdb?currentSchema=nodeA_schema',
'dataSourceProperties.dataSourceClassName' : 'org.postgresql.ds.PGSimpleDataSource',
'dataSourceProperties.dataSource.user' : 'postgres',
'dataSourceProperties.dataSource.password' : 'postgres',
//'dataSourceProperties.driverClassName' : 'org.postgresql.ds.PGSimpleDataSource'
//jarDirs = ['${rootProject.projectDir}/lib/postgresql-42.2.8.jar']
//'drivers' : 'org.postgresql.Driver'
'jarDirs' : ['${rootProject.projectDir}/lib/jdbc/driver/postgresql-42.2.8.jar']
]
//jarDirs = ['${rootProject.projectDir}/lib/postgresql-42.2.8.jar']
//drivers = ext.drivers
}
// NODEB
node {
name "O=NODEB,L=Delhi,C=IN"
p2pAddress("localhost:10010")
rpcSettings {
address("localhost:10011")
adminAddress("localhost:10052")
}
rpcUsers = [[user: "userB", "password": "user123", "permissions": ["ALL"]]]
//new DB config
//DB
extraConfig = [
'dataSourceProperties.dataSource.url' : 'jdbc:postgresql://localhost:5432/egdb?currentSchema=nodeB_schema',
'dataSourceProperties.dataSourceClassName' : 'org.postgresql.ds.PGSimpleDataSource',
'dataSourceProperties.dataSource.user' : 'postgres',
'dataSourceProperties.dataSource.password' : 'postgres',
//'dataSourceProperties.driverClassName' : 'org.postgresql.ds.PGSimpleDataSource'
//jarDirs = ['${rootProject.projectDir}/lib/postgresql-42.2.8.jar']
//'drivers' : 'org.postgresql.Driver'
'jarDirs' : ['${rootProject.projectDir}/lib/jdbc/driver/postgresql-42.2.8.jar']
]
//jarDirs = ['${rootProject.projectDir}/lib/postgresql-42.2.8.jar']
//drivers = ext.drivers
}
}
How to add the postgresql jdbc driver path in build.gradle file? What is the compatible postgresql verion with corda 4.5?
答案1
得分: 5
它通过在 build.gradle
文件的 dependencies 部分中添加以下行来解决了我的问题:
cordaDriver "org.postgresql:postgresql:42.2.8"
英文:
It resolved the issue for me by adding the following line in build.gradle
file in the dependencies section:
cordaDriver "org.postgresql:postgresql:42.2.8"
答案2
得分: 0
根据这篇文章:
- PostgreSQL 9.6 是最低可接受的版本,文章使用的是 PostgresSQL 11。
- 驱动程序版本是 postgresql-42.1.4.jar。
- 为了将 Gradle 任务指向驱动程序,创建一个文件夹(称其为
drivers
),将驱动程序的 jar 文件放入其中,然后在节点的extraConfig
中添加drivers = ['绝对路径到包含jdbc驱动程序的目录']
(注意这是对你创建的目录的绝对路径,而不是像你之前所做的驱动程序文件的路径)。 - 你的节点配置缺少
database.transactionIsolationLevel
、database.schema
和database.runMigration
。 - 移除
jarDirs
并像我之前提到的那样添加drivers
。
英文:
According to this article:
- PostgreSQL 9.6 is the lowest acceptable version, the article uses PostgresSQL 11.
- The driver version is postgresql-42.1.4.jar.
- In order to point your Gradle task to the driver; create a folder (call it
drivers
), put the driver's jar file inside of it, then insideextraConfig
of your node, adddrivers = ['absolute_path_to_directory_with_jdbc_driver']
(notice that it's the absolute path to the directory that you created, not the driver file like you did). - Your node configuration is missing
database.transactionIsolationLevel
,database.schema
, anddatabase.runMigration
. - Remove
jarDirs
and adddrivers
like I mentioned earlier.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论