Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support JDBC driver for iSeries DB2 #930

Open
wants to merge 25 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
d4645b0
added jt400 driver and basic DB2 Dialect
May 27, 2020
3eee137
Update exposed-core/src/main/kotlin/org/jetbrains/exposed/sql/vendors…
V3lop5 Mar 7, 2021
9bcd454
Merge remote-tracking branch 'jb/master'
V3lop5 May 1, 2021
2841976
Changed DB2FunctionProvider to internal object
V3lop5 May 2, 2021
b5ef8b9
Added support for db2 LUW
V3lop5 May 2, 2021
3ad3164
Added non working db2 test database
V3lop5 May 2, 2021
fe70789
Applied db2-tests patch from @Tapac
V3lop5 May 13, 2021
6705356
hide output from docker ibm/db2 image
V3lop5 May 30, 2021
657b142
do not specify NULL on column definition for db2
V3lop5 May 30, 2021
fd4aa18
Merge branch 'JetBrains:master' into master
V3lop5 Jun 25, 2021
b8de500
Merge branch 'master' of https://github.com/JetBrains/Exposed into Je…
V3lop5 Mar 14, 2022
c9e318c
Merge branch 'JetBrains-master'
V3lop5 Mar 14, 2022
9d05134
Added db2 test
V3lop5 Mar 14, 2022
024162a
db2 resultset compat
Mar 20, 2022
056c36f
local db2 config
Mar 20, 2022
3db771a
fix limit
Mar 20, 2022
31b63d0
db2 column type and functionProvider
Mar 20, 2022
747349e
make dual sysdummy1 in db2
Mar 20, 2022
e083b8e
fix insert tests,fix table exists in db2,fix seq max number in db2
Mar 20, 2022
2cf2243
fix tableExist
Mar 20, 2022
1d08716
fix tableNames for db2
sola1tmy Mar 20, 2022
c9eb572
ignore some tests which db2 not support
sola1tmy Mar 20, 2022
134b89e
union did't gurantee the order,so I sort the result to compare in tes…
sola1tmy Mar 20, 2022
d6a2ac6
ignore 2 tests
sola1tmy Mar 20, 2022
e1684dc
Merge pull request #19 from sola1tmy/newdb2
V3lop5 Mar 24, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ class Database private constructor(private val resolvedVendor: String? = null, v
registerDialect(OracleDialect.dialectName) { OracleDialect() }
registerDialect(SQLServerDialect.dialectName) { SQLServerDialect() }
registerDialect(MariaDBDialect.dialectName) { MariaDBDialect() }
registerDialect(DB2Dialect.dialectName) { DB2Dialect() }
}

fun registerDialect(prefix:String, dialect: () -> DatabaseDialect) {
Expand Down Expand Up @@ -131,6 +132,7 @@ class Database private constructor(private val resolvedVendor: String? = null, v
url.startsWith("jdbc:oracle") -> "oracle.jdbc.OracleDriver"
url.startsWith("jdbc:sqlite") -> "org.sqlite.JDBC"
url.startsWith("jdbc:sqlserver") -> "com.microsoft.sqlserver.jdbc.SQLServerDriver"
url.startsWith("jdbc:as400") -> "com.ibm.as400.access.AS400JDBCDriver"
else -> error("Database driver not found for $url")
}

Expand All @@ -143,6 +145,7 @@ class Database private constructor(private val resolvedVendor: String? = null, v
url.startsWith("jdbc:oracle") -> OracleDialect.dialectName
url.startsWith("jdbc:sqlite") -> SQLiteDialect.dialectName
url.startsWith("jdbc:sqlserver") -> SQLServerDialect.dialectName
url.startsWith("jdbc:as400") -> DB2Dialect.dialectName
else -> error("Can't resolve dialect for connection: $url")
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package org.jetbrains.exposed.sql.vendors

import org.jetbrains.exposed.sql.*

internal object DB2DataTypeProvider : DataTypeProvider() {
override fun binaryType(): String {
exposedLogger.error("The length of the Binary column is missing.")
error("The length of the Binary column is missing.")
}

override fun dateTimeType(): String = "TIMESTAMP"

override fun ulongType(): String = "BIGINT"

override fun textType(): String = "VARCHAR(32704)"
}

internal open class DB2FunctionProvider : FunctionProvider() {
internal object INSTANCE : DB2FunctionProvider()

override fun random(seed: Int?) = "RAND(${seed?.toString().orEmpty()})"
}

/**
* DB2 dialect implementation.
*/
class DB2Dialect : VendorDialect(dialectName, DB2DataTypeProvider, DB2FunctionProvider.INSTANCE) {
override val name: String = dialectName
override val functionProvider: FunctionProvider = MariaDBFunctionProvider
V3lop5 marked this conversation as resolved.
Show resolved Hide resolved
override val supportsOnlyIdentifiersInGeneratedKeys: Boolean = true


companion object {
/** DB2 dialect name */
const val dialectName: String = "db2"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class JdbcDatabaseMetadataImpl(database: String, val metadata: DatabaseMetaData)
"pgjdbc-ng" -> PostgreSQLNGDialect.dialectName
"PostgreSQL JDBC Driver" -> PostgreSQLDialect.dialectName
"Oracle JDBC driver" -> OracleDialect.dialectName
"AS/400 Toolbox for Java JDBC Driver" -> DB2Dialect.dialectName
else -> {
if (driverName.startsWith("Microsoft JDBC Driver "))
SQLServerDialect.dialectName
Expand Down