# How to include JDBC into Kotlin project?

**URL:** https://discuss.kotlinlang.org/t/how-to-include-jdbc-into-kotlin-project/21104
**Category:** Uncategorized
**Created:** [March 6, 2021, 8:37am UTC](https://discuss.kotlinlang.org/t/how-to-include-jdbc-into-kotlin-project/21104 "2021-03-06T08:37:42Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![available](https://avatars.discourse-cdn.com/v4/letter/a/90ced4/32.png) [@available](https://discuss.kotlinlang.org/u/available)
#### Post date: [March 6, 2021, 8:37am UTC](https://discuss.kotlinlang.org/t/how-to-include-jdbc-into-kotlin-project/21104/1 "2021-03-06T08:37:42Z")

</div>

I am trying to use database on Kotlin but I have got some problems. I’ve imported Java SQL lib and I found an example for trying.

The line that I get error:  
`connection = DriverManager.getConnection("jdbc:sqlite: C:/sql/database.db")`

Error:

> java.sql.SQLException: No suitable driver found for jdbc:sqlite

How can I import the **jdbc:sqlite**?

---

<div class="post-metadata">

### Author: ![Varia](https://avatars.discourse-cdn.com/v4/letter/v/b9e5f3/32.png) [@Varia](https://discuss.kotlinlang.org/u/Varia)
#### Post date: [March 6, 2021, 1:46pm UTC](https://discuss.kotlinlang.org/t/how-to-include-jdbc-into-kotlin-project/21104/2 "2021-03-06T13:46:54Z")

</div>

JDBC is just an API. In order to actually use it, you need to include a driver for the specific DBMS that you are using - in your case SQLite - as a runtime dependency. An SQLite JDBC driver is available as Maven artifact [org.xerial:sqlite-jdbc](https://mvnrepository.com/artifact/org.xerial/sqlite-jdbc).

---

<div class="post-metadata">

### Author: ![available](https://avatars.discourse-cdn.com/v4/letter/a/90ced4/32.png) [@available](https://discuss.kotlinlang.org/u/available)
#### Post date: [March 6, 2021, 2:30pm UTC](https://discuss.kotlinlang.org/t/how-to-include-jdbc-into-kotlin-project/21104/3 "2021-03-06T14:30:23Z")

</div>

Thanks but I don’t use Maven. I use Gradle.

---

<div class="post-metadata">

### Author: ![kyay10](https://avatars.discourse-cdn.com/v4/letter/k/c57346/32.png) [@kyay10](https://discuss.kotlinlang.org/u/kyay10)
#### Post date: [March 6, 2021, 2:40pm UTC](https://discuss.kotlinlang.org/t/how-to-include-jdbc-into-kotlin-project/21104/4 "2021-03-06T14:40:04Z")

</div>

Maven artifacts can be used as Gradle dependencies quite easily, in fact Gradle mainly depends on using Maven artifacts. Go [here](https://mvnrepository.com/artifact/org.xerial/sqlite-jdbc/3.34.0) to simply see how to add that artifact to your gradle projecct, but the TL;DR of it is this: `implementation group: 'org.xerial', name: 'sqlite-jdbc', version: '3.34.0'`

---

<div class="post-metadata">

### Author: ![available](https://avatars.discourse-cdn.com/v4/letter/a/90ced4/32.png) [@available](https://discuss.kotlinlang.org/u/available)
#### Post date: [March 6, 2021, 3:37pm UTC](https://discuss.kotlinlang.org/t/how-to-include-jdbc-into-kotlin-project/21104/5 "2021-03-06T15:37:36Z")

</div>

> [@kyay10](#):
>
> Go [here](https://mvnrepository.com/artifact/org.xerial/sqlite-jdbc/3.34.0) to simply see how to add

Actually it doesn’t work.

> build.gradle.kts:27:25: Expecting an element

By the way can you explain how to use Maven artifacts is used as Gradle dependicies?

---

<div class="post-metadata">

### Author: ![kyay10](https://avatars.discourse-cdn.com/v4/letter/k/c57346/32.png) [@kyay10](https://discuss.kotlinlang.org/u/kyay10)
#### Post date: [March 6, 2021, 3:40pm UTC](https://discuss.kotlinlang.org/t/how-to-include-jdbc-into-kotlin-project/21104/6 "2021-03-06T15:40:11Z")

</div>

oh you’re using `kts` that’s why. The instructions on that are for the “default” (for lack of a better word) gradle language of Groovy (i.e. which is just build.gradle without the kts). For kts, use `implementation(group = "org.xerial", name = "sqlite-jdbc", version: "3.34.0")`

---

<div class="post-metadata">

### Author: ![Varia](https://avatars.discourse-cdn.com/v4/letter/v/b9e5f3/32.png) [@Varia](https://discuss.kotlinlang.org/u/Varia)
#### Post date: [March 6, 2021, 4:47pm UTC](https://discuss.kotlinlang.org/t/how-to-include-jdbc-into-kotlin-project/21104/7 "2021-03-06T16:47:41Z")

</div>

You don’t actually need to declare it as an `implementation` dependency. `runtimeOnly` is enough:

```auto
runtimeOnly("org.xerial:sqlite-jdbc:3.34.0")

```

---

<div class="post-metadata">

### Author: ![available](https://avatars.discourse-cdn.com/v4/letter/a/90ced4/32.png) [@available](https://discuss.kotlinlang.org/u/available)
#### Post date: [March 6, 2021, 4:48pm UTC](https://discuss.kotlinlang.org/t/how-to-include-jdbc-into-kotlin-project/21104/8 "2021-03-06T16:48:15Z")

</div>

Thanks to you. @kyay10
