Kotlin - Ktorm - Oracle - Not conncetion

HI all, i’ve try to connect into an Oracle DB, but when i invoke the class with the connection i receive this error : java.sql.SQLException: No suitable driver found for jdbc:oracle:thin:.
I used ktorm to connect and use the jdbc string in this way :

jdbc:oracle:thin:@//<host_name>:<port>/<service_name>
    val db = Database.connect(url = "jdbc:oracle:thin:@//<host_name>:<port>/<service_name>",  user = "<user>", password = "<psw>")

Antoher question is where i can chose what schema i want to connect ? Because in jdb with SQL i use this syntax :

val db = Database.connect("jdbc:mysql://localhost:3306/anagrafica", user = "admin", password = "root66")

Thanks all for support

I have github project in which I use oracle database inside docker compose, you can steal my configuration here: db-messiah/compose.yaml at master · urosjarc/db-messiah · GitHub

The driver that I use is this one: runtimeOnly("com.oracle.database.jdbc:ojdbc11:23.3.0.23.09")

The connection for oracle connection is the following: (Password is: root)

@dnlcosentino Oh and of course the connection by which I connect to it is the following:

this["jdbcUrl"] = "jdbc:oracle:thin:@localhost:1521:XE"
this["username"] = "system"
this["password"] = "root"

Thanks @urosjarc , i’ve take your configuration, only two things :

  • I saw that you use gradle, but I use maven and ktorm to connect a db, so I don’t understand where I can put the driver
  • I don’t have the oracle db inside docker, I don’t konwo if this thing can be change the configuration that you suggested me.

Thansk for support, nad sorry for this question, but I’m new of configuration a microservice from zero

Oh I see, then take a look at this repository: GitHub - hvalfangst/Ktor-Koin-API-with-Flyway-Exposed-and-JWT-using-Maven: Ktor Koin API with Flyway, Exposed and JWT using Maven

Maybe this will be more appropriate for your case?

I joust google it with this search query: “maven ktor exposed”

Thanks a lot @urosjarc , i’ve resolved it also with your repository :slight_smile:
But now I’ve a new problem with the connection between my microservice that stay inside a docker and the connection of db. When I ran the microservice with a normal springboot run all connection got ok, but when I ran docker run -p 8081:8080 pecodb:springboot-v21 I receive this error :

com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure

The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.

Another stranger thing is that if i try to invoke from rest controller with this command i cannot ivoke with localhost or my IP : http://localhost:8081/api/anagrafica/helloWorld.
Whic ip I’ll invoke, and how can resolve the problem of connection ?
Thanks

You have provided too little information, if your primary problem was resolved you should create another question and mark this thread as resolved.

Ok, yes is resolved

Just a note on what exactly is a Driver class; it’s a class with specific code that knows how to talk to the database you’re trying to use. So in your case, you’re connecting to an Oracle DB, so you need a Driver class that knows how to talk to Oracle DB. I imagine there’s a Java Oracle Driver library or something that you include with your project, and inside that library is the code that knows how to talk to an Oracle DB. For MySQL, there’s the mysql-connector-java, or mysql-connector-j, which is the Java library that has code for talking to a MySQL database. What you’re doing when connecting to the database is telling the database library code which class has the code for talking to that specific database.