package org.kodejava.jdbc;
import java.sql.DatabaseMetaData;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Connection;
import java.sql.ResultSet;
public class DatabaseSupportedType {
private static final String URL = "jdbc:mysql://localhost/kodejava";
private static final String USERNAME = "kodejava";
private static final String PASSWORD = "s3cr*t";
public static void main(String[] args) {
try (Connection connection =
DriverManager.getConnection(URL, USERNAME, PASSWORD)) {
DatabaseMetaData metadata = connection.getMetaData();
ResultSet resultSet = metadata.getTypeInfo();
while (resultSet.next()) {
String typeName = resultSet.getString("TYPE_NAME");
System.out.println("Type Name = " + typeName);
}
} catch (SQLException e) {
e.printStackTrace();
}
}
}
Here are the data types supported by MySQL database:
Type Name = BIT
Type Name = TINYINT
Type Name = TINYINT UNSIGNED
Type Name = BIGINT
Type Name = BIGINT UNSIGNED
Type Name = LONG VARBINARY
Type Name = MEDIUMBLOB
Type Name = LONGBLOB
Type Name = BLOB
Type Name = VARBINARY
Type Name = TINYBLOB
Type Name = BINARY
Type Name = LONG VARCHAR
Type Name = MEDIUMTEXT
Type Name = LONGTEXT
Type Name = TEXT
Type Name = CHAR
Type Name = ENUM
Type Name = SET
Type Name = DECIMAL
Type Name = NUMERIC
Type Name = INTEGER
Type Name = INT
Type Name = MEDIUMINT
Type Name = INTEGER UNSIGNED
Type Name = INT UNSIGNED
Type Name = MEDIUMINT UNSIGNED
Type Name = SMALLINT
Type Name = SMALLINT UNSIGNED
Type Name = FLOAT
Type Name = DOUBLE
Type Name = DOUBLE PRECISION
Type Name = REAL
Type Name = DOUBLE UNSIGNED
Type Name = DOUBLE PRECISION UNSIGNED
Type Name = VARCHAR
Type Name = TINYTEXT
Type Name = BOOL
Type Name = DATE
Type Name = YEAR
Type Name = TIME
Type Name = DATETIME
Type Name = TIMESTAMP
Maven Dependencies
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
<version>8.1.0</version>
</dependency>
Latest posts by Wayan (see all)
- How do I create a string of repeated characters? - September 1, 2023
- How do I convert datetime string with optional part to a date object? - August 28, 2023
- How do I split large excel file into multiple smaller files? - April 15, 2023