473,498 Members | 1,907 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Java and access database user accounts

13 New Member
Hi All,

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
  1.  
  2. package application;
  3.  
  4. import java.sql.*;
  5. public class Test {
  6.     public static void main(String[] arguments) {
  7.         try {
  8.             Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
  9.             /* the next 3 lines are Step 2 method 2 from above - you could use the direct
  10.             access method (Step 2 method 1) istead if you wanted */
  11.             String dataSourceName = "mdbTEST";
  12.             String dbURL = "jdbc:odbc:" + dataSourceName;
  13.             Connection con = DriverManager.getConnection(dbURL, "",""); 
  14.             // try and create a java.sql.Statement so we can run queries
  15.             Statement s = con.createStatement();
  16.             s.execute("create table TEST12345 ( column_name integer )"); // create a table
  17.             s.execute("insert into TEST12345 values(1)"); // insert some data into the table 
  18.             s.execute("select column_name from TEST12345"); // select the data from the table
  19.             ResultSet rs = s.getResultSet(); // get any ResultSet that came from our query
  20.             if (rs != null) // if rs == null, then there is no ResultSet to view
  21.             while ( rs.next() ) // this will step through our data row-by-row
  22.  
  23.  
  24.                 {
  25.                 /* the next line will get the first column in our current row's ResultSet 
  26.                 as a String ( getString( columnNumber) ) and output it to the screen */ 
  27.                 System.out.println("Data from column_name: " + rs.getString(1) );
  28.             }
  29.             s.execute("drop table TEST12345");
  30.             s.close(); // close the Statement to let the database know we're done with it
  31.             con.close(); // close the Connection to let the database know we're done with it
  32.         }
  33.  
  34.  
  35.             catch (Exception err) {
  36.             System.out.println("ERROR: " + err);
  37.         }
  38.     }
  39.     }
  40.  
Jun 15 '09 #1
1 2072
JosAH
11,448 Recognized Expert MVP
Where does your database run? An Applet (nor a JApplet) can contact a database running on the client machine without some precautions. It's a security thing.

kind regards,

Jos
Jun 15 '09 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
8127
by: Daniel Pope | last post by:
Hello Everybody, I'm preparing for doing a daunting task: to access Out look Microsoft Outlook Express(regardles the operating system and Outlook version) from a Java applet (after the client...
11
9207
by: DrUg13 | last post by:
In java, this seems so easy. You need a new object Object test = new Object() gives me exactly what I want. could someone please help me understand the different ways to do the same thing in...
5
7340
by: rob | last post by:
Hi to all. I am pretty new to using Access and am having a problem I hope someone can help me with. I want to access a MS-Access database from a web page. I have managed to get it "sort" of...
5
3673
by: premmehrotra | last post by:
I currently have a multi-user access database which is put on a shared drive L: on a Windows Servers. Entire database is one file premdb.mdb. Users access this database from their laptops....
17
2455
by: DaveG | last post by:
Hi all I am planning on writing a stock and accounts program for the family business, I understand this is likely to take close to 2 years to accomplish. The stock is likely to run into over a...
2
6918
by: Jobs | last post by:
Download the JAVA , .NET and SQL Server interview with answers Download the JAVA , .NET and SQL Server interview sheet and rate yourself. This will help you judge yourself are you really worth of...
1
3889
patjones
by: patjones | last post by:
Good Evening: So, I wanted to learn a little about user accounts, because on of my databases has been put on a network drive, and I have a need to know who is entering what data into the...
14
4607
by: SimeonD | last post by:
Hi I have an access database called Sales.Mdb In vb.net 2005, I'd like to open it. Which I can do. What I can't figure out is how to figure out if Sales.Mdb is open already. If so, I want to open...
0
7125
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7004
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7167
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6890
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7379
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5464
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
3085
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
657
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
292
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.