Re: TINYINT column returning BigInteger instead of Integer
Posted by: Todd Farmer
Date: July 15, 2013 09:37AM

Hi Rana,

Please provide the definition for the affected table, and indicate which index was recently added and is seen as the potential cause of the behavior change:

mysql> SHOW CREATE TABLE tbl_name\G

Can you also clarify where the metadata is being checked? Is it ResultSetMetaData or DatabaseMetaData? I tried both, and get the expected results:

public static void testMetaData() throws Exception {
Class.forName("com.mysql.jdbc.Driver");
Properties props = new Properties();
props.setProperty("user", "root");
Connection conn = DriverManager.getConnection(
"jdbc:mysql://localhost:3308/test", props);

conn.createStatement().execute("DROP TABLE IF EXISTS md_test");
conn.createStatement().execute("CREATE TABLE md_test (a INT, b TINYINT, INDEX(b))");
conn.createStatement().execute("INSERT INTO md_test VALUES (1, 1)");
DatabaseMetaData dbmd = conn.getMetaData();
ResultSet rs = dbmd.getColumns(null, null, "md_test", null);

System.out.println("DatabaseMetaData: ");
while(rs.next()){
System.out.println(rs.getString(3) + "." + rs.getString(4) + ": " + rs.getString(6));
}

rs = conn.createStatement().executeQuery("SELECT * FROM md_test");
ResultSetMetaData rsmd = rs.getMetaData();
System.out.println("ResultSetMetaData: ");
System.out.println(rsmd.getColumnLabel(1) + ": " + rsmd.getColumnTypeName(1));
System.out.println(rsmd.getColumnLabel(2) + ": " + rsmd.getColumnTypeName(2));


rs.close();
conn.createStatement().execute("DROP TABLE IF EXISTS md_test");

}

produces the following output:

md_test.a: INT
md_test.b: TINYINT
ResultSetMetaData:
a: INT
b: TINYINT

There are some variations on how Connector/Java obtains metadata (particularly with DatabaseMetaData) - please provide the connection properties (and Connector/Java version) you are using to connect.

--
Todd Farmer
MySQL @ Oracle
http://www.oracle.com/mysql/

Options: ReplyQuote


Subject
Written By
Posted
Re: TINYINT column returning BigInteger instead of Integer
July 15, 2013 09:37AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.