![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Jun 2007
Posts: 1
Rep Power: 0
![]() |
Heeey guys!
it's the first time for me to post a thread here.. I have a big dilemma and I need your help.. I have a project at uni about making a JDBC ..here it is : Introduction JDBC (Java Database Connectivity) is a standard SQL database access interface, which provides uniform access to a wide range of relational databases. It also provides a common base on which higher-level tools and interfaces can be built. Basically, JDBC performs the following operations: • Establish a connection with a database or access any tabular data source. • Send SQL statements. • Process the results. JDBC defines a set of main interfaces to handle the previous three steps java.sql.Driver java.sql.Connection java.sql.Statement java.sql.Resultset The Driver interface handle requests for database connections, the Connection interface provide means for accessing the specified database and querying it using standard SQL queries. Each SQL query need to be passed to the connection through an object implements Statement interface, the return value of the query will be stored in an object implements ResultSet interface. The following code snippet for a simple JDBC program. // Step 1 : Establish the conenction
// First, loading the driver
Class drvClass = Class.forName(“oracle.jdbc.driver.OracleDriver”);
DriverManager.registerDriver((Driver) drvClass.newInstance());
// Second, making the connection
Connection m_con = DriverManager.getConnection(m_url, m_userName, m_password);
// Step 2: Send SQL statement
Statement stmt = m_con.createStatement();
ResultSet rs = stmt.executeUpdate("SELECT e_name, e_salary FROM employee");
// Step 3: Process the result
while (rs.next())
{
String s = rs.getString("e_name");
float n = rs.getFloat("e_salary");
System.out.println("Name: " + s + "\t Salary: " + n);
} // Close connection and release resources
stmt.close();
m_con.close();Problem Statement It is required to implement and XML JDBC deriver that access and XML database and make some queries on it. First you will need to implement a simple Database Management System ,DBMS, that handles XML tables, it is let for you to specifies the structure of your XML tables. You will use SAX parser in parsing the tables data. Second, you will implement the JDBC four main interfaces; java.sql.Driver, java.sql.Connection, java.sql.Statement and java.sql.Resultset. You won't implement all methods of the previous interfaces, instead you will use adapter classes to handle the unneeded functions for our driver as the following. java.sql.Driver Will be implemented with all its methods. java.sql.Connection Implement the following methods; close(), commit(), createStatement(), isClosed(), isReadOnly(), setReadOnly(boolean readOnly). java.sql.Statement Implement the following methods; addBatch(String sql), clearBatch(), close(), executeBatch(), executeQuery(String sql), executeUpdate(String sql), getConnection(), getMaxRows(), getQueryTimeout(), getResultSet(), getUpdateCount(), setMaxRows(int max), setQueryTimeout(). java.sql.Resultset Implement the following methods; absolute(int row), afterLast(), beforeFirst(), cancelRowUpdates(), close(), deleteRow(), findColumn(String columnName), first(), getObject(int columnIndex), getObject(String columnName), getRow(), getStatement(), insertRow(), isAfterLast(), isBeforeFirst(), isFirst(), isLast(), last(), moveToCurrentRow(), moveToInsertRow(), next(), previous(), relative(int rows) , rowDeleted(), rowInserted(), rowUpdated(), updateObject(int columnIndex), updateObject(String columnName) The resultant JDBC of your implementation should be able to run code like given in the previous example and similar codes that execute SQL quires. Our proposed XML driver will support the following SQL statements: INSERT INTO table [ column [,column, …. ]]
VALUES (value [,value, … ))
UPDATE table
SET column=value [ , column=value, .. ]
[WHERE condition]
DELETE table
[WHERE condition]
SELECT { * | column [,column, …. ] }
FROM table
WHERE conditionIn your implementation you must have a general class for logging your different error, warnings and messages. It is recommended to use Log4J project for logging ------------------------------------------------------- now I need an example of an implementation of any of the functions coz I don't know where to start!!! please this is urgent thanks a lot Evronia Last edited by DaWei; Nov 23rd, 2007 at 9:29 PM. Reason: Added code tags. Read the rules. |
|
|
|
|
|
#2 |
|
Hobbyist Programmer
Join Date: Sep 2007
Location: Sydney - Australia
Posts: 195
Rep Power: 2
![]() |
Re: Jdbc
Do your own <snip> homework pal.
__________________
SYNTAX ERROR ... Last edited by Ancient Dragon; Nov 28th, 2007 at 8:16 AM. Reason: snipped cursing |
|
|
|
|
|
#3 |
|
Programming Guru
![]() ![]() ![]() |
Re: Jdbc
A verbatim copy-and-paste of your homework. Your lack of effort literally makes me sick.
If you can't come up with a simple set of code and post a specific question, then perhaps you should re-evaluate things. Start here: google.com or your textbook. I'm not doing your homework for you unless I can have your diploma/degree, since afterall, I am the one who will be earning it.
__________________
http://jasonpowers.net "There are a thousand hacking at the branches of evil to one who is striking at the root." |
|
|
|
|
|
#4 |
|
Programmer
Join Date: Oct 2007
Posts: 41
Rep Power: 0
![]() |
Re: Jdbc
http://www.w3schools.com/sql/default.asp
Best place to start is by learning the basics http://www.kitebird.com/articles/jdbc.html http://java.sun.com/docs/books/tutorial/ Sorry I like throwing links out there. BTW does it pay to do your homework? I would love to afford to go to college to "learn" this stuff also. Send me an e-mail to how much it pays and I'll tell you if it's worth anymore of my time. Last edited by casesensitive; Nov 27th, 2007 at 10:01 AM. |
|
|
|
|
|
#5 |
|
Hobbyist Programmer
Join Date: May 2006
Location: West Jordan, Utah, United States
Posts: 176
Rep Power: 3
![]() |
Re: Jdbc
If you give clearer specifications, I could guide you in the right direction. What is your "database" going to look like? If you could give a sample, that would help. I have never used an "xml database".
|
|
|
|
|
|
#6 |
|
Programmer
Join Date: Oct 2007
Posts: 41
Rep Power: 0
![]() |
Re: Jdbc
I think he already told us everything he knew. His class assignment word for word.
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| JDBC question | metsfan | Java | 2 | May 29th, 2007 11:58 AM |
| JDBC DB2 connection | Konnor | Java | 6 | Mar 10th, 2006 6:54 PM |
| Jdbc | Dark Flare Knight | Java | 5 | Nov 19th, 2005 6:25 PM |
| Jdbc | Dark Flare Knight | Java | 1 | Nov 6th, 2005 12:47 PM |
| problem with JDBC for talking to Microsoft Access database using a Java Applet | captainK | Java | 4 | Mar 20th, 2005 11:01 AM |