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.

Beispiel für eine hsqldb

Empfohlene Antworten

Veröffentlicht

Hallo liebe Fachinformatiker. Ich habe eine hsqldb, die im Server-Modus laufen soll. Ich finde genügend Beispiele für eine Standalone-Lösung. Hier eines:

import java.sql.*;


import java.util.logging.*;




public class UseHSQLDB {


   static Logger log = Logger.getLogger("de.myname.UseHSQLDB");




   public static void main(String[] args)


      throws SQLException, ClassNotFoundException { // Doit better ...




   log.log(Level.INFO, "Starting to load JDBCDriver... ");


   Class.forName("org.hsqldb.jdbcDriver");


   log.log(Level.INFO, "JDBC Driver successfully loaded!");




   Connection con =


      DriverManager.getConnection( // tmp must exist. Right slash.


         "jdbc:hsqldb:C:/tmp/musicShop","sa","");


   //log.log(Level.INFO, "Connection established!");




   Statement stmt = con.createStatement();


   String sqlQuery =


      "CREATE TABLE cdShop (cdNr INTEGER, cdArtist CHAR(20), cdTitle CHAR(20))";


   ResultSet rs = stmt.executeQuery(sqlQuery);

   //rs = stmt.executeQuery(sqlQuery);




   sqlQuery = "INSERT INTO cdShop VALUES (1,'Groeni','Mensch')";


   rs = stmt.executeQuery(sqlQuery);


   sqlQuery = "INSERT INTO cdShop VALUES (2,'Sting','Fields of Gold')";


   rs = stmt.executeQuery(sqlQuery);


   sqlQuery = "INSERT INTO cdShop VALUES (3,'Bach','Pluratorium')";


   rs = stmt.executeQuery(sqlQuery);




   sqlQuery = "UPDATE cdShop SET cdTitle='W-Oratorium' WHERE cdNr=1";


   rs = stmt.executeQuery(sqlQuery);




   sqlQuery = "SELECT * FROM cdShop";


   rs = stmt.executeQuery(sqlQuery);


   System.out.println("\n\n\nCD Shop DB\n=============\n");


   int counter = 0;


   while (rs.next()) {


      System.out.println(counter++ +".Datensatz:");


      int cdNr = rs.getInt("cdNr");


      System.out.println("\t[cdNr ->" + cdNr + "]");


      String cdArtist = rs.getString("cdArtist");


      System.out.println("\t[cdArtist ->" + cdArtist + "]");


      String cdTitle = rs.getString("cdTitle");


      System.out.println("\t[cdTitle ->" + cdTitle + "]\n");


   }


   con.close();


   }

   }

Wie muss die Verbindung gestaltet werden, damit ich das als Server laufen lassen kann? Ich habe schon unter hsqldb.org in die Doku geschaut und finde kein Beispiel

vorher:

Connection con = DriverManager.getConnection("jdbc:hsqldb:C:/tmp/musicShop","sa","");
nachher:
Connection con = DriverManager.getConnection("jdbc:hsqldb:hsql://hostname/musicShop", "sa", "");

s'Amstel

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

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.