简体   繁体   中英

How to fetch data from a Microsoft Access database through JDBC and insert the table as a test field in an Applet

I have made a small letter game as a Java Applet. I have made a Microsoft Access Database through JBDC for the high scores.

I have managed to insert values (scores) into the database, but I am having trouble fetching them and displaying the table in the textArea of an ajFrame . I am not even sure if the connection is established. I have created the SQL statement for it.

If you've connected successfully then

   connection=DriverManager.getConnection("jdbc:odbc:databaseName");

should return you a connection object and not throw a SqlException.

So I would first check that the above is in fact the case.

Note that an applet can only talk back to its originating server (this is a security feature). So if your applet is served from server A, and your database is on server B, you should get security exceptions.

  1. Check your query with sql prompt.

  2. verify object name used (Drivermanager,Connection,TextField)

  3. Include Exception handling code for sql statements (try and catch )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM