Unverified Commit 01ce7d87 authored by 张亮's avatar 张亮 Committed by GitHub
Browse files

Merge pull request #52 from tristaZero/dev

delete hint
parents 2a64b275 f977fcc5
Loading
Loading
Loading
Loading
+2 −17
Original line number Diff line number Diff line
@@ -17,8 +17,6 @@

package io.shardingsphere.example.jdbc.fixture;

import io.shardingsphere.core.api.HintManager;

import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.PreparedStatement;
@@ -41,11 +39,9 @@ public class DataRepository {
        queryWithEqual();
        System.out.println("2.Query with IN--------------");
        queryWithIn();
        System.out.println("3.Query with Hint--------------");
        queryWithHint();
        System.out.println("4.Drop tables--------------");
        System.out.println("3.Drop tables--------------");
        dropTable();
        System.out.println("5.All done-----------");
        System.out.println("4.All done-----------");
    }
    
    private void createTable() throws SQLException {
@@ -98,17 +94,6 @@ public class DataRepository {
        }
    }

    private void queryWithHint() throws SQLException {
        String sql = "SELECT i.* FROM t_order o JOIN t_order_item i ON o.order_id=i.order_id";
        try (
                HintManager hintManager = HintManager.getInstance();
                Connection connection = dataSource.getConnection();
                PreparedStatement preparedStatement = connection.prepareStatement(sql)) {
            hintManager.addDatabaseShardingValue("t_order", "user_id", 11);
            printQuery(preparedStatement);
        }
    }

    private void printQuery(final PreparedStatement preparedStatement) throws SQLException {
        try (ResultSet resultSet = preparedStatement.executeQuery()) {
            while (resultSet.next()) {