Search
 
SCRIPT & CODE EXAMPLE
 

SQL

A good way of running a SQL query in JDBC using a parameterized statement


// Connect to the database.
Connection conn = DriverManager.getConnection(URL, USER, PASS);

// Construct the SQL statement we want to run, specifying the parameter.
String sql = "SELECT * FROM users WHERE email = ?";

// Generate a prepared statement with the placeholder parameter.
PreparedStatement stmt = conn.prepareStatement(sql);

// Bind email value into the statement at parameter index 1.
stmt.setString(1, email);

// Run the query...
ResultSet results = stmt.executeQuery(sql);

while (results.next())
{
    // ...do something with the data returned.
}

Comment

PREVIOUS NEXT
Code Example
Sql :: create sql table from script inline primary key constraint 
Sql :: script to run SP_SPACESED on all tables in DB 
Sql :: MySQL Age Counter 
Sql :: sql convert to linq online 
Sql :: mysql wait_timeout 
Sql :: mysql use password error 
Sql :: events not working db 
Sql :: veri girme SQL 
Sql :: ring MySQL create new table and insert records 
Sql :: AND Operator (AND) 
Sql :: permisos en mysql 
Sql :: mysql and 
Sql :: sql fetch next 10 rows pdo 
Sql :: NLS_NCHAR_CHARACTERSET 
Sql :: mysql update all record removing 2 hours from column 
Sql :: time mysql w3 
Sql :: oracle archivemode 
Sql :: sql developer export connections 
Sql :: mysql config slave 
Sql :: Laravel: customize or extend notifications - database model 
Sql :: plsql function that return a table 
Sql :: decalre table in sql 
Sql :: mysql offset from bottom 
Sql :: SQL Multiplication Operator 
Sql :: MySQL Quartiles in SQL query 
Sql :: How should I pass a table name into a stored proc? 
Sql :: truncate syntax in sql 
Sql :: oracle connection 
Sql :: != not working in mysql 
Sql :: generate series sqlserver 2005 
ADD CONTENT
Topic
Content
Source link
Name
5+1 =