JAVA-MANI.BLOGSPOT.COM
Friday, November 21, 2008
import java.sql.DatabaseMetaData;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Connection;
import java.sql.ResultSet;


public class DatabaseTypeInfo {
private static final String DRIVER = "com.mysql.jdbc.Driver";
private static final String URL = "jdbc:mysql://localhost/kodejava";
private static final String USERNAME = "root";
private static final String PASSWORD = "";

public static void main(String[] args) throws Exception {
Connection connection = null;
ResultSet resultSet = null;
try {
Class.forName(DRIVER);
connection = DriverManager.getConnection(URL, USERNAME, PASSWORD);

DatabaseMetaData metadata = connection.getMetaData();
resultSet = metadata.getTypeInfo();
while (resultSet.next()) {
String typeName = resultSet.getString("TYPE_NAME");
System.out.println("Type Name = " + typeName);
}
} catch (SQLException e) {
e.printStackTrace();
} finally {
if (resultSet != null) {
resultSet.close();
}
if (connection != null) {
connection.close();
}
}
}
}

Here are the data type support MySQL database:

Type Name = BIT
Type Name = BOOL
Type Name = TINYINT
Type Name = BIGINT
Type Name = LONG VARBINARY
Type Name = MEDIUMBLOB
Type Name = LONGBLOB
Type Name = BLOB
Type Name = TINYBLOB
Type Name = VARBINARY
Type Name = BINARY
Type Name = LONG VARCHAR
Type Name = MEDIUMTEXT
Type Name = LONGTEXT
Type Name = TEXT
Type Name = TINYTEXT
Type Name = CHAR
Type Name = NUMERIC
Type Name = DECIMAL
Type Name = INTEGER
Type Name = INT
Type Name = MEDIUMINT
Type Name = SMALLINT
Type Name = FLOAT
Type Name = DOUBLE
Type Name = DOUBLE PRECISION
Type Name = REAL
Type Name = VARCHAR
Type Name = ENUM
Type Name = SET
Type Name = DATE
Type Name = TIME
Type Name = DATETIME
Type Name = TIMESTAMP

0 comments:

SUBSCRIBE VIA eMAIL

Enter your email address:

Delivered by FeedBurner

Recent Posts

Firefox 3

Counter

internet companies

Live Traffic Map

Subscribe Now