SQL Oracle Java JSP JDBC MORE

What is JDBC statement ?


In simple statement we not required to execute the query.

In simple statement we write the query at the time of execution.

Syntax:

Statement stmt=con.createStatement();  

Example:

import java.sql.*; 
 class MysqlCon{  
 public static void main(String args[]){   
 try{   
 Class.forName("com.mysql.jdbc.Driver");  
   Connection con=DriverManager.getConnection( “jdbc:mysql://localhost:3306/students","root","Students@123");  
    Statement stmt=con.createStatement();   
  ResultSet rs=stmt.executeQuery("select * from students_data”); //Write the query at the time of execution 
   while(rs.next())  
    System.out.println(rs.getInt(1)+"  "+rs.getString(2)+"  "+rs.getString(3));  
   con.close();  
    }