Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Empfohlene Antworten

Veröffentlicht

Hi,

ich möchte mit einem Java Applet auf eine MySQL Datenbank zugreifen.

Hab mir dazu den MySQL Connector/J 3.0.10-stable von der MySQL Seite runtergeladen.


package myFirstApplets;


import java.sql.*;


public class MySQL extends java.applet.Applet {

	Class.forName("com.mysql.jdbc.Driver").newInstance();

	Connection conn;


	public void init() {

		conn = DriverManager.getConnection("jdbc:mysql://localhost/test?user=root&password=***");

		conn.close();

	}

}

bringt folgende Fehler:

java.lang.Error: Unaufgelöstes Kompilierungsproblem:

Syntaxfehler bei Token "(", "Identifier" erwartet

at myFirstApplets.MySQL.<init>(MySQL.java:6)

at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)

at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)

at java.lang.reflect.Constructor.newInstance(Unknown Source)

at java.lang.Class.newInstance0(Unknown Source)

at java.lang.Class.newInstance(Unknown Source)

at sun.applet.AppletPanel.createApplet(Unknown Source)

at sun.applet.AppletPanel.runLoader(Unknown Source)

at sun.applet.AppletPanel.run(Unknown Source)

at java.lang.Thread.run(Unknown Source)

Ich hab keine Ahnung was ich jetzt machen soll :-(

Benutze Eclipse 2.1.2 mit j2re 1.4.0_03

  • Autor

So stehts in der Readme des Treibers.

To connect to the database, you need to use a JDBC url with the following

format ([xxx] denotes optional url components):

jdbc:mysql://[hostname][,failoverhost...][:port]/[dbname][?param1=value1][&param2=value2].....

Hi,

wieso kompilierst du etwas, was eclipse direkt als Fehler anzeigt?

Oder hast du die Fehleranzeige bei der Eingabe deaktiviert?


import java.sql.*;


public class Start extends java.applet.Applet {


  Connection conn;


  public void init(){

    try {

      Class.forName("com.mysql.jdbc.Driver").newInstance();

      conn = DriverManager.getConnection("jdbc:mysql://localhost/test?user=root&password=***");

      conn.close();

    } catch (Exception e) {

      e.printStackTrace();

    }

  }

}

Gruß Jaraz

PS: Datenbankzugriff direkt aus einem Applet könnte schwierig werden.

Wenn es kein Applet sein muss, könntest du halt eine Client Server Applikation schreiben.

Bei nem Applet Mysql zugriff müßtest du auch das Treiber jar an den Client schicken und der Port darf nicht geblockt sein, außerdem muss die Datenbank auf dem Server laufen von dem das Applet geladen wird, falls nicht, musst du das Applet signieren.

Was willst du überhaupt machen, muss es ein Applet sein?

Gruß Jaraz

Erstelle ein Konto oder melde dich an, um einen Kommentar zu schreiben.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.