I have just started learning java. I have a good understanding of UML 2. What i am trying to do is to make a small user authentication applet.
I have completed all of the relevant connection requirements via administration in XP but i just need a little helping hand to nudge me along.
The following script works fine, but I need some direction as to how to modify it to become an applet and to display something other than "1".
Thanks in advance
Expand|Select|Wrap|Line Numbers
- package application;
- import java.sql.*;
- public class Test {
- public static void main(String[] arguments) {
- try {
- Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
- /* the next 3 lines are Step 2 method 2 from above - you could use the direct
- access method (Step 2 method 1) istead if you wanted */
- String dataSourceName = "mdbTEST";
- String dbURL = "jdbc:odbc:" + dataSourceName;
- Connection con = DriverManager.getConnection(dbURL, "","");
- // try and create a java.sql.Statement so we can run queries
- Statement s = con.createStatement();
- s.execute("create table TEST12345 ( column_name integer )"); // create a table
- s.execute("insert into TEST12345 values(1)"); // insert some data into the table
- s.execute("select column_name from TEST12345"); // select the data from the table
- ResultSet rs = s.getResultSet(); // get any ResultSet that came from our query
- if (rs != null) // if rs == null, then there is no ResultSet to view
- while ( rs.next() ) // this will step through our data row-by-row
- {
- /* the next line will get the first column in our current row's ResultSet
- as a String ( getString( columnNumber) ) and output it to the screen */
- System.out.println("Data from column_name: " + rs.getString(1) );
- }
- s.execute("drop table TEST12345");
- s.close(); // close the Statement to let the database know we're done with it
- con.close(); // close the Connection to let the database know we're done with it
- }
- catch (Exception err) {
- System.out.println("ERROR: " + err);
- }
- }
- }