get Statement from Connection - Java java.sql

Java examples for java.sql:Connection

Description

get Statement from Connection

Demo Code


import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class Main{
    public static Statement getStatement(Connection conn) {
        Statement stmt = null;/*from   w w  w  .  ja va2s  .co m*/
        try {
            if (conn != null) {
                stmt = conn.createStatement();
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return stmt;
    }
}

Related Tutorials