Skip to main content

Posts

Showing posts with the label Prepared Statement

Insert value in database using PreparedStatement in JDBC

  1: /* 2: * student.java 3: * 4: * Created on Dec 14, 2011, 7:06:14 PM 5: */ 6: 7: package pck; 8: import java.sql.*; 9: import javax.swing.JOptionPane; 10: /* 11: * 12: * @author dell_pc 13: */ 14: public class student extends javax.swing.JFrame { 15: 16: Connection con; 17: 18: ResultSet rs; 19: /** Creates new form student */ 20: public student() { 21: initComponents(); 22: } 23: 24: 25: private void btninsetActionPerformed(java.awt.event.ActionEvent evt) { 26: try { 27: String name; 28: String add; 29: int rollno; 30: name = txtname.getText(); 31: rollno = Integer.parseInt(txtroll.getText()); 32: add = txtadd.getText(); 33: Class.forName(" sun.jdbc.odbc.JdbcOdbcDriver "); 34: con = DriverManager.getConnection(" ...

JDBC Tutorial

The JDBC ( Java Database Connectivity) API defines interfaces and classes for writing database applications in Java by making database connections. Using JDBC you can send SQL, PL/SQL statements to almost any relational database. JDBC is a Java API for executing SQL statements and supports basic SQL functionality. It provides RDBMS access by allowing you to embed SQL inside Java code. Because Java can run on a thin client, applets embedded in Web pages can contain downloadable JDBC code to enable remote database access. You will learn how to create a table, insert values into it, query the table, retrieve results, and update the table with the help of a JDBC Program example. Although JDBC was designed specifically to provide a Java interface to relational databases, you may find that you need to write Java code to access non-relational databases as well. JDBC Architecture Java application calls the JDBC library. JDBC loads a driver which talks to the database. We can change...