Category : jdbc

I am building a simple Java 8 app using Vanilla JDBC to connect to a postgres database. In my getConnection() method within ConnectionUtil.java I save my connection credentials in the following variables: String url = System.getenv("DB_URL"); String username = System.getenv("DB_USERNAME"); String password = System.getenv("DB_PASSWORD"); My docker-compose.yml file is as follows: version: "3.9" services: jdbc: build: ..

Read more

The below is part of my code which is run inside a Docker container. I have already created the variables before. String mysqlUrl = "jdbc:mysql://" + mysqlHost + "/" + mysqlDatabase + "?user=" + mysqlUser + "&password=" + mysqlPass; try { mysqlConnection = DriverManager.getConnection(mysqlUrl); } catch (SQLException e) { e.printStackTrace(); } The below is the ..

Read more

I’m learning JavaEE and trying to open a connection to my SQL Server database running on a Docker image. I obviously get the "Cannot create PoolableConnectionFactory (The TCP/IP connection to the host localhost/DB_DEMO, port 1433 has failed." With docker ps -a I get 0.0.0.0:1433->1433/tcp under "Ports" for my SQL Server Image. I know that we ..

Read more

I’m using this line of code to try to connect(w/ jdbc) to a psql docker container: Connection conn = DriverManager.getConnection( "jdbc:postgresql://localhost:5431/postgres?allowPublicKeyRetrieval=true&useSSL=false&serverTimezone=UTC", "postgres", "postgres"); db name, username, and pw are all postgres. The container was created with docker run –name practice -e POSTGRES_PASSWORD=postgres -p 5431:5431 postgres Error here: org.postgresql.util.PSQLException: The connection attempt failed. at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:150) at ..

Read more

So I have this application that connects to DB via simple JDBC written in Scala. Everything works fine until I’m trying to run it inside Docker container, there I’m getting the infamous Error during processing of request: ‘No suitable driver found for "jdbc:postgresql://0.0.0.0:5439" I’ve built a fat jar and when I’m running it on my ..

Read more