ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / Developing in Java
  • Overview
  • Accessing the data files with the HFSQL functions
  • HFSQL functions in a Java project
  • Accessing HFSQL files
  • Configuring the runtime mode of Java applications using HFSQL in MacOSX
  • Accessing a MySQL, SQL Server or SQLite database by JDBC
  • Accessing the data files with the SQL functions
  • Overview
  • SQL functions in a Java project
  • Accessing HFSQL files
  • Accessing a database not in HFSQL format by JDBC
  • Using the Java RAD
  • Available RAD
  • Simple RAD pattern
  • RAD Pattern Compatible Version 11
  • Compilation errors
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Others
Stored procedures
Overview
You can start developing your application as soon as the WINDEV project is defined as being a Java project.
All types of databases can be handled in WLanguage:
  • HFSQL database.
  • database not in HFSQL format. This database can be handled by a JDBC driver or by a native access.
To handle these databases, you have the ability to use:
  • The HFSQL functions that allow you to handle the data files directly (HFSQL database, MySQL database accessed by JDBC, SQL Server database accessed by JDBC).
  • The SQL functions that allow you to handle the data files directly (HFSQL database or database accessed by JDBC (MySQL, SQL Server, Oracle, DB2, ...)).
  • The Java RADthat allows you to quickly develop windows that handle data files.
Accessing the data files with the HFSQL functions
A JAVA application developed with WINDEV allows you to handle data files regardless of the platform where the Java application is run (Windows, Linux or Mac).
The use of a database from a Java application can be performed by the HFSQL functions. The libraries of the WINDEV Framework being available in these environments, the access to the HFSQL database via the HFSQL functions is immediate.
Remark: If "Automatically create the data files if not found when they are opened" is checked (in the description window of the project, "Files" tab), the corresponding data files will be automatically created if necessary.
HFSQL functions in a Java project

Accessing HFSQL files

The method for handling HFSQL files in a Java project is the same as the method for handling HFSQL files in a Windows project.
Depending on the runtime platform (Windows, Linux or MacOSX), the libraries required to access the HFSQL databases may vary. For more details, see Managing databases in the WINDEV Java applications.
Remark: By default, the data files are installed with the Java archive. However, the data files can be installed in another directory. In this case, you must specify the new path in the application with HChangeDir.

Configuring the runtime mode of Java applications using HFSQL in MacOSX

The minimum version of MacOSX required for using the HFSQL databases with a Java application is 10.5.8.
WINDEVJavaODBCNative Connectors (Native Accesses)

Accessing a MySQL, SQL Server or SQLite database by JDBC

To handle the data files described in the analysis of a Java project, you must:
  1. Describe a connection with HDescribeConnection or HOpenConnection. When defining this connection, you must specify the JDBC driver to use.
  2. Associate this connection to the different analysis files with HChangeConnection.
    Example for a connection to a MySQL database:
    HOpenConnection("MyMySQLConnection", "Login", "Password", ...
    "jdbc:mysql://MyServer/MyDatabase", "MyDatabase", ...
    hAccesJDBCMySQL, 0, "com.mysql.jdbc.Driver")
    HChangeConnection("*", "MyMySQLConnection")

    Example for connecting to an SQLite database:
    SQLiteConnection is Connection

    // Connection parameters
    SQLiteConnection.Provider = hAccessJDBCSQLite
    SQLiteConnection.Server = "jdbc:sqlite:mydatabase.db"
    SQLiteConnection.Access = hOReadWrite
    SQLiteConnection.ExtendedInfo = "org.sqlite.JDBC"
    // Open the connection
    HOpenConnection(SQLiteConnection)

    Notes about the SQLite access:
    • Name and Password have no effect,
    • The Server property allows you to set the name and location of the database file (in this case: the file is named mydatabase.db and is located in the application runtime directory).
  3. When the connection is defined, the HFSQL functions can be used to handle the records found in the data files.
Accessing the data files with the SQL functions

Overview

A JAVA application developed with WINDEV allows you to handle data files regardless of the platform where the Java application is run (Windows, Linux or Mac).
The use of a database from a Java application can be performed by the SQL functions. The libraries of the WINDEV Framework being available in these environments, the access to the HFSQL database via the SQL functions is immediate.
SQL functions in a Java project
WINDEVJavaHFSQL ClassicHFSQL Client/Server

Accessing HFSQL files

To handle the HFSQL data files described in the analysis of a Java project, you must:
  1. Describe a connection with SQLConnect. When defining this connection, you must specify the analysis used (.WDD file) as well as the database (HFSQL).
    Example:
    nConnectionNum is int
    nConnectionNum = SQLConnect("JavaClient.wdd", "", "", "", "HYPER FILE", "", "")
  2. When the connection is defined, the HFSQL functions can be used to handle the records found in the HFSQL data files.
Remarks:
  • By default, the data files are installed with the Java archive. However, the data files can be installed in another directory. In this case, you must specify the new path in the application with HChangeDir.
  • To access the HFSQL files, the following libraries and the Java archive of the application must be found in the same directory (they are automatically copied by WINDEV during the Java generation):
    • in Windows: wd290hf.dll, wd290sql.dll, wd290jav.dll, wd290vm.dll and wd290uni.dll. Windows libraries are located in the "Programs" subdirectory of the WINDEV installation directory.
    • in Linux: wd290hf.so, wd290sql.so, wd290jav.so, wd290vm.so and wd290uni.so. The Linux libraries are located in the "Programs\Framework" subdirectory of the WINDEV installation directory.
    • in MacOSX: wd290hf.dylib, wd290sql.dylib, wd290jav.dylib and wd290vm.dylib. The MacOSX libraries are located in the "Programs\Framework" subdirectory of the WINDEV installation directory.
  • The analysis file (WDD file) specified in the syntax of SQLConnect must be accessible from the Java application.
WINDEVJavaODBC

Accessing a database not in HFSQL format by JDBC

To handle the data files described in the analysis of a Java project, you must:
  1. Describe a connection with SQLConnect. When defining this connection, you must specify the analysis used (.WDD file) as well as the database (HFSQL).
    Example for a connection to a MySQL database:
    nConnectionNum is int
    nConnectionNum = SQLConnect("jdbc:mysql://Venus/test", "test", ...
    "mysql", "", "JDBC", DriverNameMysqlName)
  2. Once the connection is established, use the SQL functions to handle the records found in the data files.
Using the Java RAD
WINDEVJavaHFSQL ClassicHFSQL Client/ServerNative Connectors (Native Accesses)

Available RAD

As for any WINDEV project associated with an analysis, the RAD can be used to generate the windows of your Java application.
You have the ability to create form windows, table windows, ... The Java RAD takes into account all the specific features of Java generation (controls, processes, functions that can be used in a WINDEV application generated in Java).
Two types of RAD patterns can be directly used in Java:
  • The simple RAD pattern.
  • The 'Compatible 11' RAD pattern.
The code generated by the other patterns must be adapted to operate in Java.
WINDEVJavaHFSQL ClassicHFSQL Client/ServerNative Connectors (Native Accesses)

Simple RAD pattern

This pattern is adapted for generating a Java application. As for any WINDEV project associated with an analysis, the RAD can be used to generate the windows of your Java application.
Remark: By default, the simple RAD pattern handles HFSQL files. If you want to use a connection by JDBC, you must adapt the generated code. To do so, describe the connection to use (HDescribeConnection or HOpenConnection) by specifying the JDBC driver to use. This connection is associated with the different analysis files by HChangeConnection.
Example for a connection to a MySQL database:
HOpenConnection("MyMySQLConnection", "Login", "Password", ...
"jdbc:mysql://MyServer/MyDatabase", "MyDatabase", ...
hAccesJDBCMySQL, 0, "com.mysql.jdbc.Driver")
HChangeConnection("*", "MyMySQLConnection")
WINDEVJavaHFSQL ClassicHFSQL Client/ServerNative Connectors (Native Accesses)

RAD Pattern Compatible Version 11

Regardless of the type of window to generate, the first screen of the wizard allows you to enter the type of connection to the database:
  • HFSQL.
  • JDBC.
By selecting "HFSQL", the standard wizard for window creation is proposed.
For a connection via a JDBC driver, the next step of the window creation allows you to specify the parameters for connecting to the database using the JDBC driver:
The windows generated by Java RAD use the SQL functions of WLanguage. The connection to the database is established with SQLConnect.
WINDEVJavaHFSQL ClassicHFSQL Client/ServerNative Connectors (Native Accesses)

Compilation errors

A Java RAD developed in WINDEV 10 or earlier may trigger compilation errors in version 18 for the controls found in the tabs.
To solve these errors, the name of the control must be prefixed by the name of the tab to which it belongs. For example, for a control named "MyControl" that belongs to the tab named "MyTab", use the following notation: "MyTab.MyControl".
Minimum version required
  • Version 9
Comments
Click [Add] to post a comment

Last update: 09/07/2023

Send a report | Local help