Introduction to Java Database Connectivity (JDBC) PATH 2

Meta Data
- Meta data is the information about the database:
        - e.g. the number of columns, the types of the columns
        - meta data is the schema information


Accessing Meta Data
- The getMetaData() method can be used on a ResultSet object to create its meta data object.
- e.g.
ResultSetMetaData md = rs.getMetaData();

Using Meta Data
int numCols = md.getColumnCount();
for (int i = 0; i <= numCols; i++) {  
    if (md.getColumnType(i) == Types.CHAR)
   System.out.println( md.getColumnName(i) )
}

More Meta Data Methods
_ getTableName()
- getPrecision()
       number of decimal digits in the column
- isSigned()
       returns true if column has signed numbers
- isCurrency()
- etc.

Using MS Access
MS Access changed its file formats when Access 2007 was released:
       - for Access 2003 (and earlier) you should use Books.mdb
       - for Access 2007 or 2010, you should use Books.accdb
       - both versions are in the lab's website.

Access and SQL
- How to use SQL in Access is described at:
      http://www.jaffainc.com/SQLStatementsInAccess.htm


TableRelationships in Books.accdb

Books.accdb as an ODBC Data Source




Data Source Problems
- Two problems may occur when using JDBC with the data source set up in Section 8:
       -"No suitable driver found for jdbc: odbc: driver={Microsoft Access Driver (*.mdb)};...
       - "The specified DSN contains an architecture mismatch between the Driver and Application"
       - These problems are usually due to you using the 64-bit version of Windows 7.


Win7 64-bit & Access 64-bit
- You may need to download the 64-bit Access drivers from:
     http://www.microsoft.com/ en-us/download/details.aspx?id=13255
- You should also be using the 64-bit version of Java for Windows. get it from:
     http://www.java.com/en/download/
- Set up the data source using the 32-bit ODBC control panel at:
    c:\windows\sysWOW64\odbcad32.exe
- You should also be using the 32-bit version of Java for Windows. Get it from:
    http://www.java.com/en/download/



Comments

Popular posts from this blog

interpreter กับ compiler ต่างกันยังไง?

Source file not compile Dev C++ win 8, win 8.1 , win10

LTE CAT3/4/6 + มือถือ 4G ซื้อให้ดีต้องดูถึง Network Technology Bands