Class JDBCExamples

java.lang.Object
  |
  +--JDBCExamples

public class JDBCExamples
extends java.lang.Object

An example class illustrating the use of JDBC facilities with the Java-in-SQL feature of ASE 12.0.

The methods of this class perform a range of SQL operations. These methods can be invoked either from a Java client, using the "main" method, or from the SQL server, using the "internalMain" method.


Method Summary
static java.lang.String caller(java.sql.Connection con)
          A JDBCExamples method to call a stored procedure, passing input and output parameters of datatype String and Address.
static java.sql.Connection connecter(java.lang.String server)
          A JDBCExamples method to get a connection.
static java.lang.String doAction(java.lang.String action, java.sql.Connection con, java.lang.String locale)
          A JDBCExamples method to route to the action to be performed
static java.lang.String doSQL(java.sql.Connection con, java.lang.String action)
          A JDBCExamples method to execute an SQL statement.
static void main(java.lang.String[] args)
          Invokes the other methods, based on the 2nd command line parameter.
static java.lang.String selecter(java.sql.Connection con)
          A JDBCExamples method to retrieve a certain row of the "xmp" table.
static java.lang.String serverMain(java.lang.String action)
          A JDBCExamples method equivalent to the main method, to be called from SQL or Java in the server
static java.lang.String updater(java.sql.Connection con)
          A method that updates a certain row of the "xmp" table.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

main

public static void main(java.lang.String[] args)
Invokes the other methods, based on the 2nd command line parameter.

Usage:

  java JDBCExamples server-name:port-number action
  

serverMain

public static java.lang.String serverMain(java.lang.String action)
A JDBCExamples method equivalent to the main method, to be called from SQL or Java in the server

connecter

public static java.sql.Connection connecter(java.lang.String server)
                                     throws java.lang.Exception,
                                            java.sql.SQLException,
                                            java.lang.ClassNotFoundException
A JDBCExamples method to get a connection. It can be called from the server with argument "default", or from a client, with an argument that is the server name.

doAction

public static java.lang.String doAction(java.lang.String action,
                                        java.sql.Connection con,
                                        java.lang.String locale)
                                 throws java.lang.Exception
A JDBCExamples method to route to the action to be performed

doSQL

public static java.lang.String doSQL(java.sql.Connection con,
                                     java.lang.String action)
                              throws java.lang.Exception
A JDBCExamples method to execute an SQL statement.

updater

public static java.lang.String updater(java.sql.Connection con)
                                throws java.lang.Exception
A method that updates a certain row of the "xmp" table. This method illustrates prepared statements and parameter markers.

selecter

public static java.lang.String selecter(java.sql.Connection con)
                                 throws java.lang.Exception
A JDBCExamples method to retrieve a certain row of the "xmp" table. This method illustrates prepared statements, parameter markers, and result sets.

caller

public static java.lang.String caller(java.sql.Connection con)
                               throws java.lang.Exception
A JDBCExamples method to call a stored procedure, passing input and output parameters of datatype String and Address. This method illustrates callable statements, parameter markers, and result sets.