Skip to content

Commit

Permalink
[CONJ-705] prepare statement getMetaData() now return null in case of…
Browse files Browse the repository at this point in the history
… command that cannot be prepared as JDBC requires
  • Loading branch information
rusher committed May 14, 2020
1 parent eb6ce24 commit 05a9f75
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ private void loadParametersData() throws SQLSyntaxErrorException {
// if error is due to wrong SQL syntax, better to throw exception immediately
throw sqlSyntaxErrorException;
} catch (SQLException sqle) {
parameterMetaData = new MariaDbParameterMetaData(null);
// eat
}
}

Expand Down
17 changes: 11 additions & 6 deletions src/test/java/org/mariadb/jdbc/MariaDbDatabaseMetaDataTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,9 @@

package org.mariadb.jdbc;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.*;

import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.*;
import org.junit.Test;

public class MariaDbDatabaseMetaDataTest extends BaseTest {
Expand Down Expand Up @@ -94,4 +90,13 @@ private void checkResults(Connection connection, boolean yearAsDate, boolean tin
assertEquals(yearAsDate ? null : "5", rs.getString(7)); // column size
assertEquals(yearAsDate ? null : "0", rs.getString(9)); // decimal digit
}

@Test
public void metadataNullWhenNotPossible() throws SQLException {
try (PreparedStatement preparedStatement =
sharedConnection.prepareStatement(
"LOAD DATA LOCAL INFILE 'dummy.tsv' INTO TABLE LocalInfileInputStreamTest (id, test)")) {
assertNull(preparedStatement.getParameterMetaData());
}
}
}

0 comments on commit 05a9f75

Please sign in to comment.