JDBC

JDBC Projects

JDBC Project 1

Basic Operations on JDBC
Previous Home Next

JDBC Select Statement

This statement is used to retrieve the record from the database it may be single or multiple or both. And result is return into the Result Set object, which is used for display the record. For show the next record of table we can used next() method of Result Set. The syntax of the select statement is given bellow—

PreparedStatement stm=con.prepareStatement(“select * from sam”);

JDBC Insert Statement

Insert statement is used to inter the record into the table of the database.If the field has a primary key then we can insert only unique record into the table. The syntax of the insert statement is listed bellow—

PreparedStatement stm=con.prepareStatement(“insert into sam values(‘?’,’?’,’?’)”);

JDBC Update Statement

With help of the JDBC update statement, we can update the particular record of the table using java application program. And JDBC Update Statement object returns an int value that Represent the number of the Updated row in the table.The syntax of the update statement is listed bellow-

PreparedStatement 
stm=con.prepareStatement(“update sam set name=’suhani’ where id=101”);

JDBC Delete statement

JDBC delete statement is allow you to delete the particular record of the table in database or delete more than one record from the table of database. The syntax of the delete statement is listed bellow-

PreparedStatement stm=con.prepareStatement(“DELETE * from sam where id=101”);

 

Connection To The Database with use of Network Address

If you are want to connect the database over a network then need to get network address of database and also need to identify the network port number of the database. The default port no of Oracle database is 1521 and default host name is system.

A JDBC URL is providing a way of identify a database host, so that the driver loaded for database. After identifying the port no of database, you must provide a database name. Suppose that if you want to connect an oracle database with your application over a network then we are load the com.mysql.jdbc.Driver.

Then we are specifying the connection URL. MySql conection URL syntax is given bellow-

jdbc:mysql://[host][,failoverhost...][:port]/[database] »
[?propertyName1][=propertyValue1][&propertyName2][=propertyValue2]...
Previous Home Next

Tolal:0 Click:

Show All Comments

Did not find what you were looking for leave your name and message. We will revert within 24 hours
Name:
eMail:
Comment / Feedback: