Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

Backslash being added to Java Prepared Statement before special characters

Backslash being added to Java Prepared Statement before special characters

New Contributor

Using the below class with JDBC41 driver I'm running a Prepared Statement and passing "speed (km/h)" as parameter. It is being returned as "speed \(km/h\)"

public static void main(String[] args) {
        try {
            String url = "jdbc:impala://[DB_IP]:[PORT]/default;impala_db=true;auth=noSasl;UseNativeQuery=1";
            Connection conn = DriverManager.getConnection(url,"","");
            ResultSet rs;

            String Query = "select '22' as ?";
            PreparedStatement selectQuery = conn.prepareStatement(Query);

            selectQuery.setString(1, args[0]);

            rs = selectQuery.executeQuery();

            ResultSetMetaData rsmd = rs.getMetaData();

            while ( rs.next() ) {
                String s = rs.getString( 1 );
                String name = rsmd.getColumnName(1);
                System.out.println(name + " " + s);
            }
            conn.close();
        } catch (Exception e) {
            System.err.println("Got an exception! ");
            System.err.println(e.getMessage());
        }
    }
Don't have an account?
Coming from Hortonworks? Activate your account here