package com.example.bot.spring;

import org.apache.commons.dbcp.BasicDataSource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

import java.net.URI;
import java.net.URISyntaxException;

@Configuration
@ComponentScan(basePackages = "com.example.bot.spring")
public class MainConfig {

    @Bean
    public BasicDataSource dataSource() throws URISyntaxException {
        URI dbUri = new URI(System.getenv("DATABASE_URL"));

        String username = dbUri.getUserInfo().split(":")[0];
        String password = dbUri.getUserInfo().split(":")[1];
        String dbUrl = "jdbc:postgresql://" + dbUri.getHost() + dbUri.getPath();

        BasicDataSource basicDataSource = new BasicDataSource();
        basicDataSource.setUrl(dbUrl);
        basicDataSource.setUsername(username);
        basicDataSource.setPassword(password);

        return basicDataSource;
    }
}
@@ -37,224 +37,29 @@
 ort 
-org.apache.commons.dbcp.BasicDataSource;%0Aimport org.springframework.context.annotation.Bean;%0Aimport org.springframework.context.annotation.ComponentScan;%0Aimport org.springframework.context.annotation.Configura
+java.sql.Connec
 tion;%0A
-%0A
 impo
@@ -70,725 +70,418 @@
 ava.
-net.URI;%0Aimport java.net.URISyntaxException;%0A%0A@Configuration%0A@ComponentScan(basePackages = %22com.example.bot.spring%22)%0Apublic class MainConfig %7B%0A%0A    @Bean%0A    public BasicDataSource dataSource() throws URISyntaxException %7B%0A        URI dbUri = new URI(System.getenv(%22DATABASE_URL%22))
+sql.DriverManager;%0A%0Apublic class PostgreSQLJDBC %7B%0A    public void dataSource() %7B%0A    %09Connection c = null
 ;%0A
-%0A
     
-    String username = dbUri.getUserInfo().split(%22:%22)%5B0%5D;%0A        String password = dbUri.getUserInfo().split(%22:%22)%5B1%5D;%0A        String dbUrl = %22jdbc:postgresql://%22 + dbUri.getHost() + dbUri.getPath();%0A%0A        BasicDataSource basicDataSource = new BasicDataSource();%0A        basicDataSource.setUrl(dbUrl);%0A        basicDataSource.setUsername(username
+%09try%7B%0A    %09%09Class.forName(%22org.postgresql.Driver%22);%0A    %09%09c = DriverManager.getConnection(%22jdbc:postgresql://ec2-54-83-48-188.compute-1.amazonaws.com:5432/dd0o9u061jj8k6%22,%22okkpzunfngqddy%22,%0A    %09%09%09%223368af043d89677c824553247b1026010cad749945f4e6a3f03e8d6173e0d92c%22
 );%0A    
-  
-  basicDataSource.setPassword(password);%0A%0A        return basicDataSource;
+%09%7D catch (Exception e)%7B%0A    %09%7D
 %0A   

Add existing file