Mysql: desc table -> JDBC rs.getString("COLUMN_SIZE")

"Michael Niedermair" <[email protected]> Sun, 17 Sep 2017 17:33:21 +0200
Newsgroups gmane.comp.db.mysql.java
Message-ID <trinity-aa31c333-e6e2-41be-80a6-ca53c21fe08f-1505662401665@3c-app-gmx-bs21>
Hello,
I have the following table in MySQL:

mysql> desc VEREIN;
+---------+-------------+------+-----+---------+----------------+
| Field   | Type        | Null | Key | Default | Extra          |
+---------+-------------+------+-----+---------+----------------+
| V_ID    | int(11)     | NO   | PRI | NULL    | auto_increment |
| Name    | varchar(50) | NO   |     | NULL    |                |
| Strasse | varchar(50) | YES  |     | NULL    |                |
| O_ID    | int(11)     | YES  | MUL | NULL    |                |
+---------+-------------+------+-----+---------+----------------+
4 rows in set (0,00 sec)

The field V_ID  has a length of 11=2E

Now I want to output the metadata via JDBC=2E

DatabaseMetaData meta =3D con=2EgetMetaData();
ResultSet rs =3D meta=2EgetColumns(catalog,schema,"VEREIN",null);
System=2Eout=2Eprintln("Spalte\tType\tGr=C3=B6=C3=9Fe\tDezimal\tNULL\tPosi=
tion");
while(rs=2Enext()) {
  System=2Eout=2Eprint(rs=2EgetString("COLUMN_NAME")+"\t"+
    rs=2EgetString("TYPE_NAME")+"\t"+ rs=2EgetString("COLUMN_SIZE")+"\t"+
    rs=2EgetString("DECIMAL_DIGITS")+"\t"+
    rs=2EgetString("NULLABLE")+"\t"+ rs=2EgetString("ORDINAL_POSITION"));
  System=2Eout=2Eprintln();
}

The output for V_ID is:
V_ID  INT  10  0  0  1

Why is a length of 10 displayed for JDBC and 11 for MySQL?

Only this line was found in the documentation=2E
COLUMN_SIZE int =3D> column size=2E

By
Michael


-- 
MySQL Java Mailing List
For list archives: http://lists.mysql.com/java
To unsubscribe:    http://lists.mysql.com/java