APPLET / NOTES</>↗Applet22 Mar 2007
package org.kodejava.applet; import java.applet.Applet; import java.awt.Color; import java.awt.Graphics; public class AppletParameterExample extends Applet { private String name = ""; public void init() { // Here we read a parameter named name from the applet tag definition // in our html file. name = getParameter("name"); } public void paint(Graphics g) { g.setColor(Color.BLUE); g.drawString("Hello " + name […]
CORE API / NOTES</>↗Core API19 Mar 2007
package org.kodejava.util; import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class StringDateToLong { public static void main(String[] args) { // Here we have a string date, and we want to covert it to long value String today = "25/09/2021"; // Create a SimpleDateFormat which will be used to convert the string to // a […]
JDBC / NOTES</>↗JDBC19 Mar 2007
Since JDBC 2.0 (JDK 1.2), a scrollable ResultSet was introduced to the java.sql API family. Using this ResultSet enables us to navigate the result set in forward or backward way. To enable the scrollable ResultSet, we need to create a statement object by defining the ResultSet type (ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.TYPE_SCROLL_INSENSITIVE). If you define the ResultSet type […]
JDBC / NOTES</>↗JDBC15 Mar 2007
In this example we are showing you how to use result set absolute() and relative() method to jump from one result set row to the other. When you pass a positive number as the parameter, you’ll move from the first record to the last. But if you pass a negative number as parameter, you’ll move […]
JDBC / NOTES</>↗JDBC12 Mar 2007
Moving through the result set, you might want to know in what row is the current cursor positioned. To get this information, you can call the ResultSet’s getRow() method. package org.kodejava.jdbc; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; public class ScrollableGetRowExample { private static final String URL = "jdbc:mysql://localhost/kodejava"; private static final […]
JDBC / NOTES</>↗JDBC08 Mar 2007
On the previous example, we check for the beginning of the result-set. Now using the isAfterLast() method we can check the opposite whether the pointer is at the end of the result set. package org.kodejava.jdbc; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; public class ScrollableAfterLastExample { private static final String URL = […]