SlideShare a Scribd company logo
Working with database
Agenda
• Building web application using JDBC
• Handling Exception
• Using JNDI with JDBC
• Using ServletConfig in an application
• Using ServletContext
• Understanding JPA
JDBC Revisited
JDBC provides a standard library for accessing relational
databases
– API standardizes
• Way to establish connection to database
• Approach to initiating queries
• Method to create stored (parameterized) queries
• The data structure of query result (table)
JDBC Revisited
JDBC provides a standard library for accessing relational
databases
– Determining the number of columns
– Looking up metadata, etc.
– API does not standardize SQL syntax
• JDBC is not embedded SQL
– JDBC classes are in the java.sql package
• Note: JDBC is not officially an acronym;
unofficially, “Java DataBase Connectivity”
JDBC Drivers
JDBC consists of two parts:
– JDBC API, a purely Java-based API
– JDBC Driver Manager, which communicates with
vendor-specific drivers that perform the real communication
with the database.
• Point: translation to vendor format is performed on the client
– No changes needed to server
– Driver (translator) needed on client
JDBC Data Types
Seven Steps in JDBC
1. Load the driver
2. Define the Connection URL
3. Establish the Connection
4. Create a Statement object
5. Execute a query
6. Process the results
7. Close the connection
Using Metadata
System-wide data
– connection.getMetaData().getDatabaseProductName()
– connection.getMetaData().getDatabaseProductVersion()
• Table-specific data
– resultSet.getMetaData().getColumnCount()
• When using the result, remember that the index starts at 1, not
0
– resultSet.getMetaData().getColumnName()
Using Metadata(Example)
public class NorthwindServlet extends HttpServlet {
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
… out.println(docType + …);
String driver = "sun.jdbc.odbc.JdbcOdbcDriver";
String url = "jdbc:odbc:Northwind";
String username = "";
String password = ""; String tableName =
request.getParameter("tableName");
if ((tableName == null) || (tableName.equals("")))
{
tableName = "employees";
}
showTable(driver, url, username, password,
tableName, out);
out.println("</CENTER></BODY></HTML>");
Using Metadata(Example) cont
private void showTable(String driver,
String url,
String username,
String password,
String tableName,
PrintWriter out) {
try {
Class.forName(driver);
Connection connection =
DriverManager.getConnection(url, username,
password);
DatabaseMetaData dbMetaData =
connection.getMetaData();
out.println("<UL>");
String productName =
dbMetaData.getDatabaseProductName();
out.println(" <LI><B>Database:</B> " +
productName);
String productVersion =
dbMetaData.getDatabaseProductVersion();
out.println(" <LI><B>Version:</B> " +
Using Metadata(Example) cont
• Statement statement = connection.createStatement();
• String query =
• "SELECT * FROM " + tableName;
• ResultSet resultSet = statement.executeQuery(query);
• out.println("<TABLE BORDER=1>");
• ResultSetMetaData resultsMetaData =
• resultSet.getMetaData();
• int columnCount = resultsMetaData.getColumnCount();
• out.println("<TR>");
• for(int i=1; i<columnCount+1; i++) {
• out.print("<TH>" +
• resultsMetaData.getColumnName(i));
• }
• out.println();
• while(resultSet.next()) {
• out.println("<TR>");
• for(int i=1; i<columnCount+1; i++) {
• out.print("<TD>" + resultSet.getString(i));
Using Metadata Output
Using JNDI
• • Idea
• – Use abstract name to get connection from a data source
• • Advantages
• – Lets you change data source without changing code
• – Available in multiple Web apps
• • Disadvantage
• – Requires server-specific registration of data source
• • Code for steps 1-3 replaced by:
• Context context = new InitialContext();
• DataSource dataSource = (DataSource)context.lookup
• ("java:comp/env/jdbc/dbName");
• Connection connection = dataSource.getConnection();
Configuring DataSource for JNDI
• Inside tomcat_dir/conf/server.xml
<DefaultContext reloadable="true">
<Resource name="jdbc/Northwind"
auth="Container"
type="javax.sql.DataSource"/>
<ResourceParams name="jdbc/Northwind">
<parameter>
<name>factory</name>
<value>
org.apache.commons.dbcp.BasicDataSourceFactory
</value>
</parameter>
<parameter><name>driverClassName</name>
<value>sun.jdbc.odbc.JdbcOdbcDriver</value>
</parameter>
<parameter><name>url</name>
<value>jdbc:odbc:Northwind</value></parameter
<parameter><name>username</name>
<value></value></parameter>
<parameter><name>password</name>
<value></value></parameter>
Transactions
Tranactions
– By default, after each SQL statement is executed the
changes are automatically committed to the database
– Turn auto-commit off to group two or more statements
together into a transaction
connection.setAutoCommit(false)
– Call commit to permanently record the changes to the
database after executing a group of statements
– Call rollback if an error occurs
Transactions example
Connection connection =
DriverManager.getConnection(url, username, passwd);
connection.setAutoCommit(false);
try {
statement.executeUpdate(...);
statement.executeUpdate(...);
connection.commit();
} catch (Exception e) {
try {
connection.rollback();
} catch (SQLException sqle) {
// report problem
}
} finally {
try {
connection.close();
} catch (SQLException sqle) { }
}
Transactions
• getAutoCommit/setAutoCommit
– By default, a connection is set to auto-commit
– Retrieves or sets the auto-commit mode
• commit
– Force all changes since the last call to commit to become
permanent
– Any database locks currently held by this Connection
object are released
• rollback
– Drops all changes since the previous call to commit
– Releases any database locks held by this Connection object
Using ServletConfig and Servlet
• Use ServletConfig for Servlet Specifc Information
• Use ServletContext for Application Specific Information
• Configure Driver Information
• Configure URL information
• Use ServletConfig to read the data from init parameter
• Use ServletContext to read the data from context parameter
Introduction to JPA
• What is ORM
• Become acquainted with the Java Persistence API (JPA)
• Learn how to setup and use JPA
What is ORM
•ORM stands for Object Relational Mapping
• POJO’s directly mapped to Database tables
• ORM framework takes care of
- Synchronization
- Transaction
- Performance
- Database Independence
JPA Architecture
Main Components of JPA
•Entity Classes
• Entity Manager
– Persistence Context
• EntityManagerFactory
• EntityTransaction
• Persistence Unit
– persistence.xml
• Java Persistence Query Language
(JPAQL)
– Query
Persistence Unit
•Defines all entity classes that are managed by JPA
• Identified in the persistence.xml configuration file
• Entity classes and configuration files are packaged together
– The JAR or directory that contains the persistence.xml is called the root of
the persistence unit
– Needs to be inside a META-INF directory
• Whether or not inside a jar
Benefits of ORM
•No need to deal with the SQL Queries to save and retrieve the data
•Simple configuration
•Standardized API to persist the business objects
•Fast development of application
•Concurrency support
•Excellent cashing support for better performance of the
application
•Injected transaction management
•Configurable logging
•Easy to learn and use
Drawback of ORM
•Slow performance in case of large batch updates
• Little slower than JDBC
Summary
• We can connect directly to the database or to a database registered
in an Directory Service
• Use init parameter and Context parameter for database specific
configuration information
• JPA is a standard ORM specification
• JPA can take care of boiler plate code like
- Try catch block
- Obtaining Connection
- Mapping of Datatypes
- Synchronizing models with tables

More Related Content

What's hot (20)

PDF
JSR-222 Java Architecture for XML Binding
Heiko Scherrer
 
PPT
java jdbc connection
Waheed Warraich
 
PPTX
Liquibase for java developers
Illia Seleznov
 
KEY
JDBC Basics (In 20 Minutes Flat)
Craig Dickson
 
PDF
JPA and Hibernate Performance Tips
Vlad Mihalcea
 
PPTX
Java database connectivity
Atul Saurabh
 
PPT
JDBC Java Database Connectivity
Ranjan Kumar
 
PPTX
DataBase Connectivity
Akankshaji
 
PPT
Jaxb
Manav Prasad
 
PPTX
1. java database connectivity (jdbc)
Fad Zulkifli
 
PPT
Chap3 3 12
Hemo Chella
 
PPT
Jdbc
lathasiva
 
PPT
JDBC Tutorial
Information Technology
 
PPTX
Database Access With JDBC
Dharani Kumar Madduri
 
PDF
22jdbc
Adil Jafri
 
PPT
WebLogic Deployment Plan Example
James Bayer
 
PDF
XML parsing using jaxb
Malintha Adikari
 
PPS
Jdbc api
kamal kotecha
 
PDF
JAXB: Create, Validate XML Message and Edit XML Schema
Sitdhibong Laokok
 
JSR-222 Java Architecture for XML Binding
Heiko Scherrer
 
java jdbc connection
Waheed Warraich
 
Liquibase for java developers
Illia Seleznov
 
JDBC Basics (In 20 Minutes Flat)
Craig Dickson
 
JPA and Hibernate Performance Tips
Vlad Mihalcea
 
Java database connectivity
Atul Saurabh
 
JDBC Java Database Connectivity
Ranjan Kumar
 
DataBase Connectivity
Akankshaji
 
1. java database connectivity (jdbc)
Fad Zulkifli
 
Chap3 3 12
Hemo Chella
 
Jdbc
lathasiva
 
JDBC Tutorial
Information Technology
 
Database Access With JDBC
Dharani Kumar Madduri
 
22jdbc
Adil Jafri
 
WebLogic Deployment Plan Example
James Bayer
 
XML parsing using jaxb
Malintha Adikari
 
Jdbc api
kamal kotecha
 
JAXB: Create, Validate XML Message and Edit XML Schema
Sitdhibong Laokok
 

Similar to Advance java session 5 (20)

PDF
Jdbc
haribee2000
 
PDF
Presentation for java data base connectivity
kanjariya006
 
PDF
Evolution of database access technologies in Java-based software projects
Tom Mens
 
PPT
JDBC.ppt
Jayaprasanna4
 
PDF
Connect2014 Show104: Practical Java
panagenda
 
PPT
Hibernate
Preetha Ganapathi
 
PPTX
Hibernate in XPages
Toby Samples
 
PDF
Jdbc
mishaRani1
 
PDF
Advance Java Practical file
varun arora
 
PDF
JDBC in Servlets
Eleonora Ciceri
 
PPT
Basic Hibernate Final
Rafael Coutinho
 
PDF
10 jdbc
snopteck
 
PDF
10 jdbc
snopteck
 
PDF
Java Web Programming [3/9] : Servlet Advanced
IMC Institute
 
PPTX
Module-3 for career and JFSD ppt for study.pptx
ViratKohli78
 
PDF
Java Web Programming Using Cloud Platform: Module 3
IMC Institute
 
PDF
Free Hibernate Tutorial | VirtualNuggets
Virtual Nuggets
 
PPT
jdbc_presentation.ppt
DrMeenakshiS
 
PPTX
Java Database Connectivity (JDBC) ppt by Aamir Rafique.pptx
AamirRafique14
 
Presentation for java data base connectivity
kanjariya006
 
Evolution of database access technologies in Java-based software projects
Tom Mens
 
JDBC.ppt
Jayaprasanna4
 
Connect2014 Show104: Practical Java
panagenda
 
Hibernate in XPages
Toby Samples
 
Advance Java Practical file
varun arora
 
JDBC in Servlets
Eleonora Ciceri
 
Basic Hibernate Final
Rafael Coutinho
 
10 jdbc
snopteck
 
10 jdbc
snopteck
 
Java Web Programming [3/9] : Servlet Advanced
IMC Institute
 
Module-3 for career and JFSD ppt for study.pptx
ViratKohli78
 
Java Web Programming Using Cloud Platform: Module 3
IMC Institute
 
Free Hibernate Tutorial | VirtualNuggets
Virtual Nuggets
 
jdbc_presentation.ppt
DrMeenakshiS
 
Java Database Connectivity (JDBC) ppt by Aamir Rafique.pptx
AamirRafique14
 
Ad

More from Smita B Kumar (20)

PPTX
Advance java session 20
Smita B Kumar
 
PPTX
Advance java session 19
Smita B Kumar
 
PPTX
Advance java session 18
Smita B Kumar
 
PPTX
Advance java session 17
Smita B Kumar
 
PPTX
Advance java session 16
Smita B Kumar
 
PPTX
Advance java session 15
Smita B Kumar
 
PPTX
Advance java session 14
Smita B Kumar
 
PPTX
Advance java session 13
Smita B Kumar
 
PPTX
Advance java session 12
Smita B Kumar
 
PPTX
Advance java session 11
Smita B Kumar
 
PPTX
Advance java session 10
Smita B Kumar
 
PPTX
Advance java session 9
Smita B Kumar
 
PPTX
Advance java session 8
Smita B Kumar
 
PPTX
Advance java session 7
Smita B Kumar
 
PPTX
Advance java session 6
Smita B Kumar
 
PPTX
Advance java session 4
Smita B Kumar
 
PPTX
Advance java session 3
Smita B Kumar
 
PPTX
Advance java session 2
Smita B Kumar
 
PPTX
JEE session 1
Smita B Kumar
 
PPTX
01 introduction to struts2
Smita B Kumar
 
Advance java session 20
Smita B Kumar
 
Advance java session 19
Smita B Kumar
 
Advance java session 18
Smita B Kumar
 
Advance java session 17
Smita B Kumar
 
Advance java session 16
Smita B Kumar
 
Advance java session 15
Smita B Kumar
 
Advance java session 14
Smita B Kumar
 
Advance java session 13
Smita B Kumar
 
Advance java session 12
Smita B Kumar
 
Advance java session 11
Smita B Kumar
 
Advance java session 10
Smita B Kumar
 
Advance java session 9
Smita B Kumar
 
Advance java session 8
Smita B Kumar
 
Advance java session 7
Smita B Kumar
 
Advance java session 6
Smita B Kumar
 
Advance java session 4
Smita B Kumar
 
Advance java session 3
Smita B Kumar
 
Advance java session 2
Smita B Kumar
 
JEE session 1
Smita B Kumar
 
01 introduction to struts2
Smita B Kumar
 
Ad

Recently uploaded (20)

PDF
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
PDF
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
PDF
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
PDF
IoT-Powered Industrial Transformation – Smart Manufacturing to Connected Heal...
Rejig Digital
 
PDF
Biography of Daniel Podor.pdf
Daniel Podor
 
PDF
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
PDF
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
PDF
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
PDF
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
PDF
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
PDF
Staying Human in a Machine- Accelerated World
Catalin Jora
 
PDF
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
PDF
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
DOCX
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
PDF
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
PDF
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
PDF
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
PDF
July Patch Tuesday
Ivanti
 
PDF
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
IoT-Powered Industrial Transformation – Smart Manufacturing to Connected Heal...
Rejig Digital
 
Biography of Daniel Podor.pdf
Daniel Podor
 
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
Staying Human in a Machine- Accelerated World
Catalin Jora
 
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
July Patch Tuesday
Ivanti
 
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 

Advance java session 5

  • 2. Agenda • Building web application using JDBC • Handling Exception • Using JNDI with JDBC • Using ServletConfig in an application • Using ServletContext • Understanding JPA
  • 3. JDBC Revisited JDBC provides a standard library for accessing relational databases – API standardizes • Way to establish connection to database • Approach to initiating queries • Method to create stored (parameterized) queries • The data structure of query result (table)
  • 4. JDBC Revisited JDBC provides a standard library for accessing relational databases – Determining the number of columns – Looking up metadata, etc. – API does not standardize SQL syntax • JDBC is not embedded SQL – JDBC classes are in the java.sql package • Note: JDBC is not officially an acronym; unofficially, “Java DataBase Connectivity”
  • 5. JDBC Drivers JDBC consists of two parts: – JDBC API, a purely Java-based API – JDBC Driver Manager, which communicates with vendor-specific drivers that perform the real communication with the database. • Point: translation to vendor format is performed on the client – No changes needed to server – Driver (translator) needed on client
  • 7. Seven Steps in JDBC 1. Load the driver 2. Define the Connection URL 3. Establish the Connection 4. Create a Statement object 5. Execute a query 6. Process the results 7. Close the connection
  • 8. Using Metadata System-wide data – connection.getMetaData().getDatabaseProductName() – connection.getMetaData().getDatabaseProductVersion() • Table-specific data – resultSet.getMetaData().getColumnCount() • When using the result, remember that the index starts at 1, not 0 – resultSet.getMetaData().getColumnName()
  • 9. Using Metadata(Example) public class NorthwindServlet extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html"); PrintWriter out = response.getWriter(); … out.println(docType + …); String driver = "sun.jdbc.odbc.JdbcOdbcDriver"; String url = "jdbc:odbc:Northwind"; String username = ""; String password = ""; String tableName = request.getParameter("tableName"); if ((tableName == null) || (tableName.equals(""))) { tableName = "employees"; } showTable(driver, url, username, password, tableName, out); out.println("</CENTER></BODY></HTML>");
  • 10. Using Metadata(Example) cont private void showTable(String driver, String url, String username, String password, String tableName, PrintWriter out) { try { Class.forName(driver); Connection connection = DriverManager.getConnection(url, username, password); DatabaseMetaData dbMetaData = connection.getMetaData(); out.println("<UL>"); String productName = dbMetaData.getDatabaseProductName(); out.println(" <LI><B>Database:</B> " + productName); String productVersion = dbMetaData.getDatabaseProductVersion(); out.println(" <LI><B>Version:</B> " +
  • 11. Using Metadata(Example) cont • Statement statement = connection.createStatement(); • String query = • "SELECT * FROM " + tableName; • ResultSet resultSet = statement.executeQuery(query); • out.println("<TABLE BORDER=1>"); • ResultSetMetaData resultsMetaData = • resultSet.getMetaData(); • int columnCount = resultsMetaData.getColumnCount(); • out.println("<TR>"); • for(int i=1; i<columnCount+1; i++) { • out.print("<TH>" + • resultsMetaData.getColumnName(i)); • } • out.println(); • while(resultSet.next()) { • out.println("<TR>"); • for(int i=1; i<columnCount+1; i++) { • out.print("<TD>" + resultSet.getString(i));
  • 13. Using JNDI • • Idea • – Use abstract name to get connection from a data source • • Advantages • – Lets you change data source without changing code • – Available in multiple Web apps • • Disadvantage • – Requires server-specific registration of data source • • Code for steps 1-3 replaced by: • Context context = new InitialContext(); • DataSource dataSource = (DataSource)context.lookup • ("java:comp/env/jdbc/dbName"); • Connection connection = dataSource.getConnection();
  • 14. Configuring DataSource for JNDI • Inside tomcat_dir/conf/server.xml <DefaultContext reloadable="true"> <Resource name="jdbc/Northwind" auth="Container" type="javax.sql.DataSource"/> <ResourceParams name="jdbc/Northwind"> <parameter> <name>factory</name> <value> org.apache.commons.dbcp.BasicDataSourceFactory </value> </parameter> <parameter><name>driverClassName</name> <value>sun.jdbc.odbc.JdbcOdbcDriver</value> </parameter> <parameter><name>url</name> <value>jdbc:odbc:Northwind</value></parameter <parameter><name>username</name> <value></value></parameter> <parameter><name>password</name> <value></value></parameter>
  • 15. Transactions Tranactions – By default, after each SQL statement is executed the changes are automatically committed to the database – Turn auto-commit off to group two or more statements together into a transaction connection.setAutoCommit(false) – Call commit to permanently record the changes to the database after executing a group of statements – Call rollback if an error occurs
  • 16. Transactions example Connection connection = DriverManager.getConnection(url, username, passwd); connection.setAutoCommit(false); try { statement.executeUpdate(...); statement.executeUpdate(...); connection.commit(); } catch (Exception e) { try { connection.rollback(); } catch (SQLException sqle) { // report problem } } finally { try { connection.close(); } catch (SQLException sqle) { } }
  • 17. Transactions • getAutoCommit/setAutoCommit – By default, a connection is set to auto-commit – Retrieves or sets the auto-commit mode • commit – Force all changes since the last call to commit to become permanent – Any database locks currently held by this Connection object are released • rollback – Drops all changes since the previous call to commit – Releases any database locks held by this Connection object
  • 18. Using ServletConfig and Servlet • Use ServletConfig for Servlet Specifc Information • Use ServletContext for Application Specific Information • Configure Driver Information • Configure URL information • Use ServletConfig to read the data from init parameter • Use ServletContext to read the data from context parameter
  • 19. Introduction to JPA • What is ORM • Become acquainted with the Java Persistence API (JPA) • Learn how to setup and use JPA
  • 20. What is ORM •ORM stands for Object Relational Mapping • POJO’s directly mapped to Database tables • ORM framework takes care of - Synchronization - Transaction - Performance - Database Independence
  • 22. Main Components of JPA •Entity Classes • Entity Manager – Persistence Context • EntityManagerFactory • EntityTransaction • Persistence Unit – persistence.xml • Java Persistence Query Language (JPAQL) – Query
  • 23. Persistence Unit •Defines all entity classes that are managed by JPA • Identified in the persistence.xml configuration file • Entity classes and configuration files are packaged together – The JAR or directory that contains the persistence.xml is called the root of the persistence unit – Needs to be inside a META-INF directory • Whether or not inside a jar
  • 24. Benefits of ORM •No need to deal with the SQL Queries to save and retrieve the data •Simple configuration •Standardized API to persist the business objects •Fast development of application •Concurrency support •Excellent cashing support for better performance of the application •Injected transaction management •Configurable logging •Easy to learn and use
  • 25. Drawback of ORM •Slow performance in case of large batch updates • Little slower than JDBC
  • 26. Summary • We can connect directly to the database or to a database registered in an Directory Service • Use init parameter and Context parameter for database specific configuration information • JPA is a standard ORM specification • JPA can take care of boiler plate code like - Try catch block - Obtaining Connection - Mapping of Datatypes - Synchronizing models with tables