package io.shardingjdbc.example.proxy;

import io.shardingjdbc.example.proxy.repository.RawJdbcRepository;
import org.apache.commons.dbcp.BasicDataSource;

import javax.sql.DataSource;
import java.sql.SQLException;

/*
 * Please make sure start sharding-proxy before you run this example.
 */
public final class ServerMain {
    
    public static void main(String[] args) throws SQLException {
        RawJdbcRepository rawJdbcRepository = new RawJdbcRepository(createDataSource());
        rawJdbcRepository.demo();
    }
    
    private static DataSource createDataSource() {
        BasicDataSource result = new BasicDataSource();
        result.setDriverClassName(com.mysql.jdbc.Driver.class.getName());
        result.setUrl("jdbc:mysql://localhost:3307/sharding_db?useServerPrepStmts=true");
        result.setUsername("root");
        result.setPassword("");
        return result;
    }
}

@@ -319,24 +319,138 @@
 Main %7B%0A    %0A
+    private static final String PROXY_IP = %22localhost%22;%0A    %0A    private static final int PROXY_PORT = 3307;%0A    %0A
     public s
@@ -843,36 +843,41 @@
 Url(
-%22jdbc:mysql://localhost:3307
+String.format(%22jdbc:mysql://%25s:%25d
 /sha
@@ -909,16 +909,39 @@
 ts=true%22
+, PROXY_IP, PROXY_PORT)
 );%0A     

update sharding-proxy-example