The topics that should be covered for learning JDBC
I have been asked to learn JDBC. I do not know where to start. I have started with some books. It's using some SQL tables (I am also new to SQL)开发者_高级运维. So I want any of you to assist me that the topics that should be covered for JDBC. I also want to know how to creae a simple DB in Windows, so that database will be connected to my program.
Which books, materials are useful to know for:
- Java Beginners
- JDBC
- Connection between Java & JDBC (I do not know whether its right or not)
- Relation between Java & SQL.
Java Beginners
Head to Sun Oracle's own tutorials.
- The Java Tutorials - Getting started
- The Java Tutorials - Learning the Java language
- The Java Tutorials - Essential Classes
- The Java Tutorials - Collections
JDBC
Again, the vendor's own tutorials are the best (only learn it after basic Java!):
- The Java Tutorials - JDBC basics
You'd like to learn SQL first beforehand (learn it before JDBC):
- W3Schools - SQL tutorial
Connection between Java & JDBC (I do not know whether its right or not)
JDBC is a Java API (a set of interfaces and classes). There is no such thing as "connect between Java and JDBC". You rather want to connect between Java and the database. You use JDBC for this. You first need to know the JDBC URL of the database in question and the login username and password. Then you can connect it like follows:
Connection connection = DriverManager.getConnection(url, username, password);
How the URL should look like depends on the DB and JDBC driver in question. You'd like to consult the documentation of the JDBC driver in question.
Relation between Java & SQL.
Nothing. Both are separate and independent languages each with an own purpose. SQL is a database communication language. Java is an object oriented programming language. In Java, you can use the JDBC API to execute SQL programmatically, but that's also really all.
I also want to know how to creae a simple DB in Windows, so that database will be connected to my program
Just choose a database server and download and install it. There are several popular choices:
- MySQL - JDBC driver
- PostgreSQL - JDBC driver
- Oracle - JDBC driver
- MS SQL Server - JDBC driver (jTDS JDBC driver is better)
- IBM DB2 - (no public JDBC driver, it's included in DB2 install folder)
Each of them also ships with DB vendor specific JDBC documentation. It's also worth to get yourself through it (only if you already understand basic JDBC!).
See also:
- JDBC tutorial with MySQL
- DAO tutorial with MySQL
Start by focusing on accessing a Database using SQL.
JDBC just lets your write Java code to call the SQL, so you need to understand SQL first, and to understand SQL you need to understand Databases a little: Tables, Columns, Keys.
So you could work through a tutorial such as this link text.
精彩评论