Skip to content
This repository was archived by the owner on Jan 18, 2024. It is now read-only.

Commit 2012e2c

Browse files
Init
1 parent fd432f9 commit 2012e2c

14 files changed

+1495
-9
lines changed

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ You should have the following things installed:
3333
* Ensure that everything is encoded in ``UTF-8``
3434
* Ensure that the JDK/Java-Version is correct
3535

36-
## Releasing [![Build](https://img.shields.io/github/actions/workflow/status/xdev-software/xdev-swing-framework-template/release.yml?branch=master)](https://github.com/xdev-software/xdev-swing-framework-template/actions/workflows/release.yml)
36+
## Releasing [![Build](https://img.shields.io/github/actions/workflow/status/xdev-software/xapi-db-db2i/release.yml?branch=master)](https://github.com/xdev-software/xapi-db-db2i/actions/workflows/release.yml)
3737

3838
Before releasing:
39-
* Consider doing a [test-deployment](https://github.com/xdev-software/xdev-swing-framework-template/actions/workflows/test-deploy.yml?query=branch%3Adevelop) before actually releasing.
39+
* Consider doing a [test-deployment](https://github.com/xdev-software/xapi-db-db2i/actions/workflows/test-deploy.yml?query=branch%3Adevelop) before actually releasing.
4040
* Check the [changelog](CHANGELOG.md)
4141

4242
If the ``develop`` is ready for release, create a pull request to the ``master``-Branch and merge the changes.

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
[![Latest version](https://img.shields.io/maven-central/v/com.xdev-software/xdev-swing-framework-template)](https://mvnrepository.com/artifact/com.xdev-software/xdev-swing-framework-template)
2-
[![Build](https://img.shields.io/github/actions/workflow/status/xdev-software/xdev-swing-framework-template/checkBuild.yml?branch=develop)](https://github.com/xdev-software/xdev-swing-framework-template/actions/workflows/checkBuild.yml?query=branch%3Adevelop)
3-
[![javadoc](https://javadoc.io/badge2/com.xdev-software/xdev-swing-framework-template/javadoc.svg)](https://javadoc.io/doc/com.xdev-software/xdev-swing-framework-template)
4-
# xdev-swing-framework-template
1+
[![Latest version](https://img.shields.io/maven-central/v/com.xdev-software/xapi-db-db2i)](https://mvnrepository.com/artifact/com.xdev-software/xapi-db-db2i)
2+
[![Build](https://img.shields.io/github/actions/workflow/status/xdev-software/xapi-db-db2i/checkBuild.yml?branch=develop)](https://github.com/xdev-software/xapi-db-db2i/actions/workflows/checkBuild.yml?query=branch%3Adevelop)
3+
[![javadoc](https://javadoc.io/badge2/com.xdev-software/xapi-db-db2i/javadoc.svg)](https://javadoc.io/doc/com.xdev-software/xapi-db-db2i)
4+
# SqlEngine Database Adapter DB2i
55

6-
A XDEV Swing Framework Template
6+
The XDEV Application Framework provides an abstraction over database dialects as part of its SqlEngine. This module is the Database Adapter for DB2i which includes the DB2i-specific implementation for database access.
77

88
## XDEV-IDE
99
The [XDEV(-IDE)](https://xdev.software/en/products/swing-builder) is a visual Java development environment for fast and easy application development (RAD - Rapid Application Development). XDEV differs from other Java IDEs such as Eclipse or NetBeans, focusing on programming through a far-reaching RAD concept. The IDE's main components are a Swing GUI builder, the XDEV Application Framework and numerous drag-and-drop tools and wizards with which the functions of the framework can be integrated.
@@ -17,4 +17,4 @@ If you need support as soon as possible and you can't wait for any pull request,
1717
See the [contributing guide](./CONTRIBUTING.md) for detailed instructions on how to get started with our project.
1818

1919
## Dependencies and Licenses
20-
View the [license of the current project](LICENSE) or the [summary including all dependencies](https://xdev-software.github.io/xdev-swing-framework-template/dependencies/)
20+
View the [license of the current project](LICENSE) or the [summary including all dependencies](https://xdev-software.github.io/xapi-db-db2i/dependencies/)

pom.xml

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@
4848

4949
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
5050
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
51+
52+
<xdev.xapi.version>6.0.1</xdev.xapi.version>
53+
<!-- We call it db2i here but it's actually jt400
54+
For more information: https://www.ibm.com/support/pages/jtopen-jdbc-driver-%E2%80%93-alternate-server-support
55+
-->
56+
<db2i.version>8.5</db2i.version>
5157
</properties>
5258

5359
<repositories>
@@ -87,7 +93,26 @@
8793
</distributionManagement>
8894

8995
<dependencies>
90-
96+
<dependency>
97+
<groupId>com.xdev-software</groupId>
98+
<artifactId>xapi</artifactId>
99+
<version>${xdev.xapi.version}</version>
100+
</dependency>
101+
102+
103+
<!-- https://mvnrepository.com/artifact/net.sf.jt400/jt400 -->
104+
<dependency>
105+
<groupId>net.sf.jt400</groupId>
106+
<artifactId>jt400</artifactId>
107+
<version>${db2i.version}</version>
108+
</dependency>
109+
110+
<dependency>
111+
<groupId>junit</groupId>
112+
<artifactId>junit</artifactId>
113+
<version>${junit.version}</version>
114+
<scope>test</scope>
115+
</dependency>
91116
</dependencies>
92117

93118
<build>

src/main/java/db2i.png

840 Bytes
Loading
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
package xdev.db.db2i.jdbc;
2+
3+
/*-
4+
* #%L
5+
* DB2i
6+
* %%
7+
* Copyright (C) 2003 - 2023 XDEV Software
8+
* %%
9+
* This program is free software: you can redistribute it and/or modify
10+
* it under the terms of the GNU Lesser General Public License as
11+
* published by the Free Software Foundation, either version 3 of the
12+
* License, or (at your option) any later version.
13+
*
14+
* This program is distributed in the hope that it will be useful,
15+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17+
* GNU General Lesser Public License for more details.
18+
*
19+
* You should have received a copy of the GNU General Lesser Public
20+
* License along with this program. If not, see
21+
* <http://www.gnu.org/licenses/lgpl-3.0.html>.
22+
* #L%
23+
*/
24+
25+
26+
import com.xdev.jadoth.sqlengine.dbms.DbmsConnectionInformation;
27+
import xdev.db.ConnectionInformation;
28+
29+
import java.sql.Connection;
30+
public class DB2iConnectionInformation extends ConnectionInformation<DB2iDbms>
31+
{
32+
// /////////////////////////////////////////////////////////////////////////
33+
// constructors //
34+
// ///////////////////
35+
36+
/**
37+
* @param user
38+
* the user
39+
* @param password
40+
* the password
41+
* @param schema
42+
* the schema
43+
* @param urlExtension
44+
* the extended url properties
45+
* @param dbmsAdaptor
46+
* the dbms adaptor
47+
*/
48+
public DB2iConnectionInformation(final String host, final int port, final String user,
49+
final String password, final String schema, final String urlExtension,
50+
final DB2iDbms dbmsAdaptor)
51+
{
52+
super(host,port,user,password,schema,urlExtension,dbmsAdaptor);
53+
}
54+
55+
56+
// /////////////////////////////////////////////////////////////////////////
57+
// getters //
58+
// ///////////////////
59+
/**
60+
* Gets the schema.
61+
*
62+
* @return the schema
63+
*/
64+
public String getSchema()
65+
{
66+
return this.getCatalog();
67+
}
68+
69+
70+
// /////////////////////////////////////////////////////////////////////////
71+
// setters //
72+
// ///////////////////
73+
/**
74+
* Sets the database.
75+
*
76+
* @param schema
77+
* the schema to set
78+
*/
79+
public void setSchema(final String schema)
80+
{
81+
this.setCatalog(schema);
82+
}
83+
84+
85+
// /////////////////////////////////////////////////////////////////////////
86+
// override methods //
87+
// ///////////////////
88+
/**
89+
* @see DbmsConnectionInformation#createJdbcConnectionUrl()
90+
*/
91+
@Override
92+
public String createJdbcConnectionUrl()
93+
{
94+
String url = "jdbc:as400://" + getHost() + ":" + getPort() + "/" + getSchema();
95+
return appendUrlExtension(url);
96+
}
97+
98+
99+
/**
100+
* @see com.xdev.jadoth.sqlengine.dbms.DbmsConnectionInformation#getJdbcDriverClassName()
101+
*/
102+
@Override
103+
public String getJdbcDriverClassName()
104+
{
105+
return "com.ibm.as400.access.AS400JDBCDriver";
106+
}
107+
108+
109+
@Override
110+
public boolean isConnectionValid(Connection connection)
111+
{
112+
try
113+
{
114+
return !connection.isClosed();
115+
}
116+
catch(Exception ignored)
117+
{
118+
// We'll just ignore the exception here.
119+
// If the try throws an exception, we know, that we have no valid connection.
120+
// Therefore, we can simply return false instead of handling the error.
121+
}
122+
123+
return false;
124+
}
125+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package xdev.db.db2i.jdbc;
2+
3+
/*-
4+
* #%L
5+
* DB2i
6+
* %%
7+
* Copyright (C) 2003 - 2023 XDEV Software
8+
* %%
9+
* This program is free software: you can redistribute it and/or modify
10+
* it under the terms of the GNU Lesser General Public License as
11+
* published by the Free Software Foundation, either version 3 of the
12+
* License, or (at your option) any later version.
13+
*
14+
* This program is distributed in the hope that it will be useful,
15+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17+
* GNU General Lesser Public License for more details.
18+
*
19+
* You should have received a copy of the GNU General Lesser Public
20+
* License along with this program. If not, see
21+
* <http://www.gnu.org/licenses/lgpl-3.0.html>.
22+
* #L%
23+
*/
24+
25+
import com.xdev.jadoth.sqlengine.dbms.standard.StandardDDLMapper;
26+
27+
28+
public class DB2iDDLMapper extends StandardDDLMapper<DB2iDbms>
29+
{
30+
protected DB2iDDLMapper(final DB2iDbms dbmsAdaptor)
31+
{
32+
super(dbmsAdaptor);
33+
}
34+
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
package xdev.db.db2i.jdbc;
2+
3+
import com.xdev.jadoth.sqlengine.SELECT;
4+
import com.xdev.jadoth.sqlengine.dbms.standard.StandardDMLAssembler;
5+
6+
7+
/*-
8+
* #%L
9+
* DB2i
10+
* %%
11+
* Copyright (C) 2003 - 2023 XDEV Software
12+
* %%
13+
* This program is free software: you can redistribute it and/or modify
14+
* it under the terms of the GNU Lesser General Public License as
15+
* published by the Free Software Foundation, either version 3 of the
16+
* License, or (at your option) any later version.
17+
*
18+
* This program is distributed in the hope that it will be useful,
19+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
20+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21+
* GNU General Lesser Public License for more details.
22+
*
23+
* You should have received a copy of the GNU General Lesser Public
24+
* License along with this program. If not, see
25+
* <http://www.gnu.org/licenses/lgpl-3.0.html>.
26+
* #L%
27+
*/
28+
public class DB2iDMLAssembler extends StandardDMLAssembler<DB2iDbms>
29+
{
30+
protected static final String _FETCH_FIRST_ = " FETCH FIRST ";
31+
32+
33+
public DB2iDMLAssembler(final DB2iDbms dbms)
34+
{
35+
super(dbms);
36+
}
37+
38+
39+
/**
40+
* @see StandardDMLAssembler#assembleSelectRowLimit(SELECT, StringBuilder, int, String, String, int)
41+
*/
42+
@Override
43+
protected StringBuilder assembleSelectRowLimit(final SELECT query, final StringBuilder sb,
44+
final int flags, final String clauseSeperator, final String newLine,
45+
final int indentLevel)
46+
{
47+
final Integer top = query.getFetchFirstRowCount();
48+
if(top != null)
49+
{
50+
sb.append(_FETCH_FIRST_).append(top).append(_ROWS_ONLY);
51+
}
52+
return sb;
53+
}
54+
}

0 commit comments

Comments
 (0)