Skip to content
Snippets Groups Projects
Commit e497f88c authored by bewe's avatar bewe
Browse files

fix: cannot connect to db

parent b4da7f7b
Branches
Tags
No related merge requests found
...@@ -17,4 +17,6 @@ services: ...@@ -17,4 +17,6 @@ services:
context: . context: .
ports: ports:
- "8080:8080" - "8080:8080"
depends_on:
- toco-soap-db
FROM mysql/mysql-server:8.0.23 FROM mysql/mysql-server:8.0.23
COPY db/toco_soap.sql /docker-entrypoint-initdb.d/ COPY db/toco_soap.sql /docker-entrypoint-initdb.d/
FROM maven:3.8.6-amazoncorretto-8 AS build FROM maven:3.8-openjdk-11-slim
COPY . /app
WORKDIR /app WORKDIR /app
RUN --mount=type=cache,target=/root/.m2 mvn clean install COPY src ./src
COPY pom.xml .
FROM amazoncorretto:8 COPY target ./target
COPY --from=build /app/target /app
WORKDIR /app
EXPOSE 8080 RUN mvn clean package
CMD java -jar toco_Soap-1.0-SNAPSHOT.jar CMD ["mvn", "exec:java"]
\ No newline at end of file \ No newline at end of file
...@@ -76,6 +76,15 @@ ...@@ -76,6 +76,15 @@
</execution> </execution>
</executions> </executions>
</plugin> </plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<mainClass>org.toco.Main</mainClass>
</configuration>
</plugin>
</plugins> </plugins>
</build> </build>
......
...@@ -6,7 +6,7 @@ public class connector { ...@@ -6,7 +6,7 @@ public class connector {
public static Connection connect() { public static Connection connect() {
String user = "toco"; String user = "toco";
String password = "toco"; String password = "toco";
String url = "jdbc:mysql://localhost:3306/toco_soap"; String url = "jdbc:mysql://toco-soap-db:3306/toco_soap";
try { try {
Class.forName("com.mysql.cj.jdbc.Driver"); Class.forName("com.mysql.cj.jdbc.Driver");
......
...@@ -9,8 +9,7 @@ import javax.jws.WebMethod; ...@@ -9,8 +9,7 @@ import javax.jws.WebMethod;
public class testing { public class testing {
@WebMethod @WebMethod
public String hello(String name) { public String hello(String name) {
connector conn = new connector(); connector.connect();
conn.connect();
return "Hello " + name + "!"; return "Hello " + name + "!";
} }
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment