Board index » jbuilder » Database Application with JB9 Personal?

Database Application with JB9 Personal?


2003-12-13 05:31:36 PM
jbuilder19
Hi!!
I am new to Java and Jbuilder.
Now I have a question: Is it possible to create Java applications that
connect, get data from and write into a MySQL Database when only using JB9
Personal or is this only possible with Prof/Enterp?
Greetings
Thorsten
 
 

Re:Database Application with JB9 Personal?

Thorsten Franke wrote:
Quote
Hi!!

I am new to Java and Jbuilder.
Now I have a question: Is it possible to create Java applications that
connect, get data from and write into a MySQL Database when only using JB9
Personal or is this only possible with Prof/Enterp?

Greetings
Thorsten

--
apas.{*word*104}magick.de / "PGP Public Key" auf Anfrage
It's possible to build Java Applications that connect to any database
(provided you have the JDBC drivers and the database of course <G>), with a
Text Editor <G>.
I would upgrade to JBX Foundation, however. JB 9 Personal's license will ot
allow you to distribute your applications. It is restricted to personal use
only, while JB X Foundation's license will allow you to distribute your
apps for personal, GPL, or Commercial use. Plus, it fixes some of the bugs
in JB 9.
Using JB 9 or JB X, there are database components that make creating
Database applications easier. However, I would suggest that you familiarize
yoursef with JDBC. Below is an example of how to make a Database connection
using straight JDBC and how to Query a Table.
Of course, the example below requires the following:
(1) You must have mySQL loaded and running on your machine.
(2) You replace the ADatabase in createConnection with a real Database Name
(remember it is case sensitive, the case of the Database Name must match
exactly the Database Name).
(3) You replace the ATable with a real table name in the
DBClass.GetSoemRecords with a real table name in the ADatabase Database.
JBuilder specific:
(4) You have downloaded the mysql JDBC Drivers
(mysql-connector-java-3.0.7-stable-bun.jar) and added this jar file to your
/jbuilderinstallpath.lib.ext path.
(5) You create a library called mysql from the Tools,Configure Libraries
Wizard, and you add the mysql-connector*.jar to the required Libraries.
(6) You Select Project/Project Properties from the Project (simplemysql) you
have created and add the mysql library to the Required Libraries tab.
(7) You compile and run the application as per below.
Text Editor :
(4) You download the mysql JDBC Drivers and install the jar file in your
/jre/lib/ext folder.
(5) You create a folder named simplemysql on your harddrive where you have
access.
(6) You open a Text editor and save your .java file below (DBClass.java and
TestConnection.java) inside the simplemysql folder.
(7) You compile the following classes, from the command line using javac
DBClass.java and then javac TestConnection.java.
(8) You type java simplemysql.TestConnection from a directory once removed
from your simplemysql folder name.
package simplemysql;
import java.sql.*;
public class DBClass {
Connection conn;
public DBClass() {
}
public String createConnection() throws ClassNotFoundException,
SQLException {
String sResult="Connection to Database was estabished.";
try {
Class.forName("com.mysql.jdbc.Driver");
/* Change the ADatabase in the string below to match your database name.
remember it is case sensitive. */
conn = DriverManager.getConnection("jdbc:mysql://localhost/ADatabase",
"root", "");
}
catch (Exception ex) {
sResult="Connecton not established";
throw new SQLException("Could not establish Connection. Reported error
was:\n"+
ex.getMessage());
}
return sResult;
}
public ResultSet getSomeRecords() throws SQLException {
/ * Change the String sql= to match your field names and the SomeTabl to
match your Table Name. */
String sql="Select FirstName,LastName,City, State from SomeTable";
ResultSet rs=this.getConnection().createStatement().executeQuery(sql);
return rs;
}
public Connection getConnection() {
if (conn == null) {
try {
createConnection();
}
catch (Exception ex) {
ex.printStackTrace();
}
}
return conn;
}
}
Here is a test class
package simplemysql;
import java.sql.*;
public class TestConnection {
public TestConnection() {
}
public static void main(String[] args) {
TestConnection tc = new TestConnection();
DBClass dbc= new DBClass();
//Make a connection to a myusql Database and display results
try {
String s=dbc.createConnection();
System.out.println(s);
}
catch (Exception ex) {
System.err.println(ex.getMessage());
}
//Query the Database and print the results a record at a time
try {
ResultSet rs = dbc.getSomeRecords();
int i=1;
while (rs.next()) {
System.out.println("Record # " + i);
/* Change the rs.getString("FieldNames") to match your actual
field names. */
System.out.println("First Name :" + rs.getString("FirstName"));
System.out.println("Last Name: "+ rs.getString("LastName"));
System.out.println("City: " +rs.getString("City"));
System.out.println("State: "+rs.getString("State"));
++i;
}
}
catch (Exception ex) {
System.err.println(ex.getMessage());
}
}
}
--Good Luck!
 

Re:Database Application with JB9 Personal?

On Sat, 13 Dec 2003 12:12:57 -0500
pNichols < XXXX@XXXXX.COM >wrote:
Quote

I would upgrade to JBX Foundation, however. JB 9 Personal's license will ot
allow you to distribute your applications. It is restricted to personal use
only, while JB X Foundation's license will allow you to distribute your
apps for personal, GPL, or Commercial use. Plus, it fixes some of the bugs
in JB 9.
Are you sure?
Lori M Olson posted a message to the dbswing newsgroup some days ago with a different opinion:
**************************************************************************
From: "Lori M Olson (TeamB)" < XXXX@XXXXX.COM >
To: borland.public.jbuilder.dbswing
Date: Wed, 19 Nov 2003 21:03:24 -0700
Subject: Re: No DataModule for Developer Edition?
----
David Orriss, Jr. wrote:
Quote
On Wed, 19 Nov 2003 13:23:01 -0800, "Steve"
< XXXX@XXXXX.COM >wrote:


>No, don't have that. That's how I figured it out that it wasn't a typo. So,
>like I said, seems strange to take away a feature in the developer version
>that's in the personal edition.


Well only kinda... Y'see.. even tho it's in the personal edition, you
can't *use* it for any commercial work due to the license restrictions
*in* the Personal edition...

Not quite, David. *Individuals* can use it for commercial work (version
9 only), but not corporations.
--
Regards,
Lori Olson (TeamB)
**************************************************************************
I can add that when I installed JBuilder 9 Personal I remenber (now I use another version) Borland Licence Manager said: "Non-commercial use licence only: NO".
 

{smallsort}