Java – Draw Rectangle in Applet Example

<applet code="DrawRectanglesExample" width=200 height=200>

import java.applet.Applet;
import java.awt.Graphics;

public class DrawRectanglesExample extends Applet {

        public void paint(Graphics g) {

                //this will draw a rectangle of width 50 & height 100 at (10,10)

                //this will draw a square

Java – JDBC 4 – Update Annotation Example

The Update annotation is used to decorate a Query interface method to update one or more records in a database table. An Update annotation must include a sql annotation type element. Here’s an example of Update annotation:

interface LoanAppDetailsQuery extends BaseQuery {
    @Update(sql="update LoanDetails set LoanStatus = ?1 where loanId = ?2")
    boolean updateLoanStatus(String loanStatus, int loanId);

Java – JDBC 4 – Select Annotation Example

Here’s an example of Select annotation to get all the active loans from the loan database:

interface LoanAppDetailsQuery extends BaseQuery {
    @Select("SELECT * FROM LoanDetais where LoanStatus = 'A'")
    DataSet<LoanApplication> getAllActiveLoans();

The sql annotation allows I/O parameters as well (a parameter marker is represented with a question mark followed by an integer). Here’s an example of a parameterized sql query.

interface LoanAppDetailsQuery extends BaseQuery {
    @Select(sql="SELECT * from LoanDetails where borrowerFirstName= ?1 and borrowerLastName= ?2")
    DataSet<LoanApplication> getLoanDetailsByBorrowerName(String borrFirstName, String borrLastName);

Page 10 of 49« First...89101112...203040...Last »