Create a MySQL Table to Store Java Types (Using Statement Objects)? : MySQL « Database « Java Tutorial

Java Tutorial
1. Language
2. Data Type
3. Operators
4. Statement Control
5. Class Definition
6. Development
7. Reflection
8. Regular Expressions
9. Collections
10. Thread
11. File
12. Generics
13. I18N
14. Swing
15. Swing Event
16. 2D Graphics
17. SWT
18. SWT 2D Graphics
19. Network
20. Database
21. Hibernate
22. JPA
23. JSP
24. JSTL
25. Servlet
26. Web Services SOA
27. EJB3
28. Spring
29. PDF
30. Email
31. J2ME
32. J2EE Application
33. XML
34. Design Pattern
35. Log
36. Security
37. Apache Common
38. Ant
39. JUnit
Java
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
C# / C Sharp
C# / CSharp Tutorial
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Tutorial » Database » MySQL 
20. 30. 5. Create a MySQL Table to Store Java Types (Using Statement Objects)?
StringBuffer tableString = new StringBuffer("CREATE TABLE mysql_all_types(");
    //                    Column Name          MySQL Type          Java Type
    tableString.append("column_boolean       BOOL, ");              // boolean
    tableString.append("column_byte          TINYINT, ");           // byte
    tableString.append("column_short         SMALLINT, " );         // short
    tableString.append("column_int           INTEGER, " );          // int
    tableString.append("column_long          BIGINT, " );           // long
    tableString.append("column_float         FLOAT, "    );         // float
    tableString.append("column_double        DOUBLE PRECISION, ");  // double
    tableString.append("column_bigdecimal    DECIMAL(13,0), "   );  // BigDecimal
    tableString.append("column_string        VARCHAR(254), "    );  // String
    tableString.append("column_date          DATE, "            );  // Date
    tableString.append("column_time          TIME, "             )// Time

    tableString.append("column_timestamp     TIMESTAMP, "         );// Timestamp
    tableString.append("column_asciistream1  TINYTEXT, "  );  // Clob (< 2^8 bytes)
    tableString.append("column_asciistream2  TEXT, "       )// Clob (< 2^16 bytes)
    tableString.append("column_asciistream3  MEDIUMTEXT, " )// Clob (< 2^24 bytes)
    tableString.append("column_asciistream4  LONGTEXT, "   )// Clob (< 2^32 bytes)
    tableString.append("column_blob1         TINYBLOB, "  );  // Blob (< 2^8 bytes)
    tableString.append("column_blob2         BLOB, "      );  // Blob (< 2^16 bytes)
    tableString.append("column_blob3         MEDIUMBLOB, " )// Blob (< 2^24 bytes)
    tableString.append("column_blob4         LONGBLOB)"   )// Blob (< 2^32 bytes)

    stmt.executeUpdate(tableString.toString());

//From Book: JDBC Recipes A Problem-Solution Approach

20. 30. MySQL
20. 30. 1. Get a MySQL Connection from the Driver Manager
20. 30. 2. MySQL Connection Properties: Passing Additional Properties Using a Database URL
20. 30. 3. Keep the Connection Alive for MySQL
20. 30. 4. MySQL Data type to Java Data type Conversion Table
20. 30. 5. Create a MySQL Table to Store Java Types (Using Statement Objects)?
20. 30. 6. Retrieve Automatically Generated Keys Using a Statement (MySQL)?
ww__w__.___j_a___v__a__2___s.c___o_m__ | Contact Us
Copyright 2003 - 08 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.