project tutorial

project tutorial - Yichuan Cai 1 using SQL in...

Info iconThis preview shows pages 1–13. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Yichuan Cai 1 using SQL in Java (JDBC)  2 Using SQL Server in ASP.net 1 using SQL in Java (JDBC)  2 Using SQL Server in ASP.net 1 Introduction (Database drive, JDBC)  2 The setup (JDBC and Eclipse)  3 Programming using SQL in Java (JDBC). Treat database as just another device connected to your computer  Driver provides you with a high level API to the database Java Database Connectivity (JDBC) is an API for the Java programming language that defines how a client may access a database.  It provides methods for querying and updating data in a database. JDBC is oriented towards relational databases. Before trying to manipulate the database using JDBC, we have to setup the JDBC and programming environment.  We will use Eclipse +JDBC + SQLserver  The first step is to download the JDBC Driver for SQL server. From http://msdn.microsoft.com/en-us/ data/aa937724.aspx First, we will open a project in Eclipse, which name is “test”. Then we have to include the external Jar “sqljdbc.jar” in the project.  Next, we have to include “class path” to the project setting. The class path refers to the absolute file path of “sqljdbc.jar” . Suppose the path is “C:/Program Files/Microsoft SQL Server 2005 JDBCDriver/sqljdbc_1.2/enu/sqljdbc.jar” The first step is to connect to SQL server  You have to specify the User name, password, database drive name, and database URL.  We will show the sample code in next slides: A piece of the sample code to connect to database: StringdriverName="com.microsoft.sqlserver.jdbc.SQLServerDriver String dbURL="jdbc:sqlserver://localhost:1433;DatabaseName=sample"; String userName="sa"; String userPwd="123456"; Connection dbConn=null; try { Class.forName(driverName); dbConn=DriverManager.getConnection(dbURL,userName,userPwd); System.out.println("Connection Successful!"); } catch(Exception e) { e.printStackTrace(); } Suppose we want to insert a tuple in the table....
View Full Document

This note was uploaded on 12/11/2009 for the course CSE 412 taught by Professor Davulcu,h during the Fall '08 term at ASU.

Page1 / 43

project tutorial - Yichuan Cai 1 using SQL in...

This preview shows document pages 1 - 13. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online