SlideShare a Scribd company logo
1 of 4
Download to read offline
DBConnectionPane.java
/*
* This class defines an extension of BorderPane that allows the user to select
* or enter a JDBC driver and a database URL, plus a username and password.
* The pane establishes a connection to that driver and URL when its Connect to
* DB button is clicked, unless there are errors. If the user later changes the
* connection, the previous connection is closed and a new one established; if
* an error occurs, the previous connection is closed and the connection
* property is set to null.
*
* The driver input combo box only offers the MySQL driver. Oracle has removed
* the JDBC-ODBC bridge driver from Java 8, and the online Oracle database
* access doesn't work for me; the page won't load.
*
* Author: Bill Rutherford
*
*/
import javafx.scene.layout.*;
import javafx.scene.control.*;
import javafx.geometry.*;
import java.sql.*;
public class DBConnectionPane extends BorderPane {
/** Database connection object */
private Connection connection;
// UI input controls
private Label lblStatus = new Label();
private ComboBox<String> cboDriver = new ComboBox<>();
private ComboBox<String> cboDatabaseURL = new ComboBox<>();
private TextField tfUsername = new TextField();
private PasswordField pfPassword = new PasswordField();
public DBConnectionPane() {
// Set up the combo boxes
cboDriver.getItems().add("com.mysql.jdbc.Driver");
cboDriver.setEditable(true);
cboDatabaseURL.getItems().addAll("jdbc:mysql://localhost/javabook",
"jdbc:mysql://localhost/test");
cboDatabaseURL.setEditable(true);
// Create UI
HBox labelPane = new HBox();
labelPane.setPadding(new Insets(5, 10, 10, 10));
labelPane.getChildren().add(lblStatus);
GridPane inputPane = new GridPane();
inputPane.setPadding(new Insets(0, 10, 0, 10));
inputPane.setHgap(10);
inputPane.setVgap(10);
inputPane.add(new Label("JDBC Drive"), 0, 0);
inputPane.add(cboDriver, 1, 0);
inputPane.add(new Label("Database URL"), 0, 1);
inputPane.add(cboDatabaseURL, 1, 1);
inputPane.add(new Label("Username"), 0, 2);
inputPane.add(tfUsername, 1, 2);
inputPane.add(new Label("Password"), 0, 3);
inputPane.add(pfPassword, 1, 3);
Button btConnect = new Button("Connect to DB");
HBox buttonPane = new HBox();
buttonPane.setPadding(new Insets(0, 10, 10, 10));
buttonPane.setAlignment(Pos.CENTER_RIGHT);
buttonPane.getChildren().add(btConnect);
setTop(labelPane);
setCenter(inputPane);
setBottom(buttonPane);
// Set button event handler
btConnect.setOnAction(e -> connectToDB());
}
// Create DB connection object and return it in the connection property
private void connectToDB() {
try {
if (connection != null) { // A previous connection was established
connection.close();
connection = null;
}
Class.forName(cboDriver.getValue()); // Load the driver
String databaseURL = cboDatabaseURL.getValue();
connection = DriverManager.getConnection(databaseURL,
tfUsername.getText(), pfPassword.getText());
lblStatus.setText("Connected to " + databaseURL);
}
catch (NullPointerException ex) {
lblStatus.setText("Please enter a driver name");
}
catch (ClassNotFoundException ex) {
lblStatus.setText("Invalid driver name, or driver not installed");
}
catch (SQLException ex) {
if (ex.getMessage().contains("Access denied"))
lblStatus.setText("Invalid username/password combination");
else if (ex.getMessage().contains("No suitable driver found"))
lblStatus.setText("Invalid database URL");
else if (ex.getMessage().contains("The url cannot be null"))
lblStatus.setText("Please enter a database URL");
else if (ex.getMessage().contains("Unknown database"))
lblStatus.setText(ex.getMessage());
else {
lblStatus.setText("Unexpected error");
ex.printStackTrace();
}
}
}
/** Return connection property */
public Connection getConnection() {
return connection;
}
}
TestDBConnectionPane.java
/*
* This program defines a DBConnectionPane class that extends BorderPane, and
* tests it. The test program displays two windows - the test window as the
* primary stage, and the DBConnectionPane window off to the left as a secondary
* stage. The test window uses the connection defined in the connection window
* to obtain and show the tables in the database when its Show Database Tables
* button is clicked.
*
* Author: Bill Rutherford
*
*/
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.stage.Stage;
import javafx.geometry.Pos;
import javafx.scene.layout.*;
import javafx.scene.control.*;
import java.sql.*;
public class TestDBConnectionPane extends Application {
private TextArea taTables = new TextArea();
@Override
public void start(Stage primaryStage) {
// Create connection pane
DBConnectionPane dbPane = new DBConnectionPane();
// Create UI for test window
Button btShowTables = new Button("Show Database Tables");
HBox buttonPane = new HBox(10);
buttonPane.setAlignment(Pos.CENTER);
buttonPane.getChildren().add(btShowTables);
taTables.setEditable(false);
taTables.setWrapText(true);
VBox testPane = new VBox(10);
testPane.getChildren().addAll(taTables, buttonPane);
// Set button event handler
btShowTables.setOnAction(e -> showDatabaseTables(dbPane));
// Set up the test pane in the primary stage and show it
Scene testScene = new Scene(testPane, 300, 150);
primaryStage.setTitle("Test DBConnectionPane");
primaryStage.setScene(testScene);
primaryStage.show();
// Create a secondary stage, set up the connection pane in it, and show
// it off to the left of the test window
Stage secondaryStage = new Stage();
Scene dbScene = new Scene(dbPane, 320, 210);
secondaryStage.setTitle("DB Connection");
secondaryStage.setScene(dbScene);
secondaryStage.setX(primaryStage.getX() - 350);
secondaryStage.setY(primaryStage.getY() - 30);
secondaryStage.show();
}
// Obtain and show the table names in the database
private void showDatabaseTables(DBConnectionPane dbPane) {
Connection connection = dbPane.getConnection();
String tables = "";
try {
DatabaseMetaData dbMetaData = connection.getMetaData();
ResultSet rsTables = dbMetaData.getTables(null, null, null,
new String[] {"TABLE"});
while (rsTables.next())
tables += (rsTables.getString("TABLE_NAME") + " ");
if (tables.equals(""))
taTables.setText("No tables in database");
else
taTables.setText(tables);
}
catch (NullPointerException ex) {
taTables.setText("Error: No connection established");
}
catch (SQLException ex) {
taTables.setText("Unexpected error");
ex.printStackTrace();
}
}
public static void main(String[] args) {
launch(args);
}
}

More Related Content

What's hot

How to execute an oracle stored procedure with nested table as a parameter fr...
How to execute an oracle stored procedure with nested table as a parameter fr...How to execute an oracle stored procedure with nested table as a parameter fr...
How to execute an oracle stored procedure with nested table as a parameter fr...Priyobroto Ghosh (Mule ESB Certified)
 
Jsp/Servlet
Jsp/ServletJsp/Servlet
Jsp/ServletSunil OS
 
JavaScript
JavaScriptJavaScript
JavaScriptSunil OS
 
Synapse india reviews on php and sql
Synapse india reviews on php and sqlSynapse india reviews on php and sql
Synapse india reviews on php and sqlsaritasingh19866
 
Mule with jdbc(my sql)
Mule with jdbc(my sql)Mule with jdbc(my sql)
Mule with jdbc(my sql)charan teja R
 
Jdbc example program with access and MySql
Jdbc example program with access and MySqlJdbc example program with access and MySql
Jdbc example program with access and MySqlkamal kotecha
 
the Spring 4 update
the Spring 4 updatethe Spring 4 update
the Spring 4 updateJoshua Long
 
Jsp standard tag_library
Jsp standard tag_libraryJsp standard tag_library
Jsp standard tag_libraryKP Singh
 
#36.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_재직자환급교육,실업자교육,국비지원교육, 자바교육,구...
#36.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_재직자환급교육,실업자교육,국비지원교육, 자바교육,구...#36.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_재직자환급교육,실업자교육,국비지원교육, 자바교육,구...
#36.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_재직자환급교육,실업자교육,국비지원교육, 자바교육,구...탑크리에듀(구로디지털단지역3번출구 2분거리)
 
Teste de Integração com DbUnit e jIntegrity
Teste de Integração com DbUnit e jIntegrityTeste de Integração com DbUnit e jIntegrity
Teste de Integração com DbUnit e jIntegrityWashington Botelho
 
#18.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_국비지원IT학원/실업자/재직자환급교육/자바/스프링/...
#18.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_국비지원IT학원/실업자/재직자환급교육/자바/스프링/...#18.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_국비지원IT학원/실업자/재직자환급교육/자바/스프링/...
#18.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_국비지원IT학원/실업자/재직자환급교육/자바/스프링/...탑크리에듀(구로디지털단지역3번출구 2분거리)
 
WORKING WITH FILE AND PIPELINE PARAMETER BINDING
WORKING WITH FILE AND PIPELINE PARAMETER BINDINGWORKING WITH FILE AND PIPELINE PARAMETER BINDING
WORKING WITH FILE AND PIPELINE PARAMETER BINDINGHitesh Mohapatra
 
Database Connection With Mysql
Database Connection With MysqlDatabase Connection With Mysql
Database Connection With MysqlHarit Kothari
 
Java Web Programming Using Cloud Platform: Module 3
Java Web Programming Using Cloud Platform: Module 3Java Web Programming Using Cloud Platform: Module 3
Java Web Programming Using Cloud Platform: Module 3IMC Institute
 

What's hot (20)

How to execute an oracle stored procedure with nested table as a parameter fr...
How to execute an oracle stored procedure with nested table as a parameter fr...How to execute an oracle stored procedure with nested table as a parameter fr...
How to execute an oracle stored procedure with nested table as a parameter fr...
 
Jsp/Servlet
Jsp/ServletJsp/Servlet
Jsp/Servlet
 
JavaScript
JavaScriptJavaScript
JavaScript
 
Synapse india reviews on php and sql
Synapse india reviews on php and sqlSynapse india reviews on php and sql
Synapse india reviews on php and sql
 
Mule with jdbc(my sql)
Mule with jdbc(my sql)Mule with jdbc(my sql)
Mule with jdbc(my sql)
 
Java beans
Java beansJava beans
Java beans
 
Jdbc example program with access and MySql
Jdbc example program with access and MySqlJdbc example program with access and MySql
Jdbc example program with access and MySql
 
Php with MYSQL Database
Php with MYSQL DatabasePhp with MYSQL Database
Php with MYSQL Database
 
the Spring 4 update
the Spring 4 updatethe Spring 4 update
the Spring 4 update
 
Jsp standard tag_library
Jsp standard tag_libraryJsp standard tag_library
Jsp standard tag_library
 
Library Project
Library ProjectLibrary Project
Library Project
 
#36.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_재직자환급교육,실업자교육,국비지원교육, 자바교육,구...
#36.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_재직자환급교육,실업자교육,국비지원교육, 자바교육,구...#36.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_재직자환급교육,실업자교육,국비지원교육, 자바교육,구...
#36.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_재직자환급교육,실업자교육,국비지원교육, 자바교육,구...
 
Plsql
PlsqlPlsql
Plsql
 
Introduction to php database connectivity
Introduction to php  database connectivityIntroduction to php  database connectivity
Introduction to php database connectivity
 
Teste de Integração com DbUnit e jIntegrity
Teste de Integração com DbUnit e jIntegrityTeste de Integração com DbUnit e jIntegrity
Teste de Integração com DbUnit e jIntegrity
 
#18.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_국비지원IT학원/실업자/재직자환급교육/자바/스프링/...
#18.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_국비지원IT학원/실업자/재직자환급교육/자바/스프링/...#18.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_국비지원IT학원/실업자/재직자환급교육/자바/스프링/...
#18.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_국비지원IT학원/실업자/재직자환급교육/자바/스프링/...
 
WORKING WITH FILE AND PIPELINE PARAMETER BINDING
WORKING WITH FILE AND PIPELINE PARAMETER BINDINGWORKING WITH FILE AND PIPELINE PARAMETER BINDING
WORKING WITH FILE AND PIPELINE PARAMETER BINDING
 
Database Connection With Mysql
Database Connection With MysqlDatabase Connection With Mysql
Database Connection With Mysql
 
Java Web Programming Using Cloud Platform: Module 3
Java Web Programming Using Cloud Platform: Module 3Java Web Programming Using Cloud Platform: Module 3
Java Web Programming Using Cloud Platform: Module 3
 
4.3 MySQL + PHP
4.3 MySQL + PHP4.3 MySQL + PHP
4.3 MySQL + PHP
 

Similar to Database Connection Pane

jdbc_presentation.ppt
jdbc_presentation.pptjdbc_presentation.ppt
jdbc_presentation.pptDrMeenakshiS
 
Java database connectivity with MYSQL
Java database connectivity with MYSQLJava database connectivity with MYSQL
Java database connectivity with MYSQLAdil Mehmoood
 
I am looking for some assistance with SQLite database. I have tried se.pdf
I am looking for some assistance with SQLite database. I have tried se.pdfI am looking for some assistance with SQLite database. I have tried se.pdf
I am looking for some assistance with SQLite database. I have tried se.pdfConint29
 
Getting Started with React v16
Getting Started with React v16Getting Started with React v16
Getting Started with React v16Benny Neugebauer
 
Tomcat连接池配置方法V2.1
Tomcat连接池配置方法V2.1Tomcat连接池配置方法V2.1
Tomcat连接池配置方法V2.1Zianed Hou
 
Java database connecticity steps
Java database connecticity stepsJava database connecticity steps
Java database connecticity stepsSKMohamedKasim
 
知っておきたいSpring Batch Tips
知っておきたいSpring Batch Tips知っておきたいSpring Batch Tips
知っておきたいSpring Batch Tipsikeyat
 
Accessing data with android cursors
Accessing data with android cursorsAccessing data with android cursors
Accessing data with android cursorsinfo_zybotech
 
Accessing data with android cursors
Accessing data with android cursorsAccessing data with android cursors
Accessing data with android cursorsinfo_zybotech
 
Java Web Programming [3/9] : Servlet Advanced
Java Web Programming [3/9] : Servlet AdvancedJava Web Programming [3/9] : Servlet Advanced
Java Web Programming [3/9] : Servlet AdvancedIMC Institute
 
Deeply Declarative Data Pipelines
Deeply Declarative Data PipelinesDeeply Declarative Data Pipelines
Deeply Declarative Data PipelinesHostedbyConfluent
 
Detail view in distributed technologies
Detail view in distributed technologiesDetail view in distributed technologies
Detail view in distributed technologiesjamessakila
 
Create a Java FX GUI program that allows the user to insert data int.pdf
Create a Java FX GUI program that allows the user to insert data int.pdfCreate a Java FX GUI program that allows the user to insert data int.pdf
Create a Java FX GUI program that allows the user to insert data int.pdfarhamnighty
 
NoSQL and JavaScript: a Love Story
NoSQL and JavaScript: a Love StoryNoSQL and JavaScript: a Love Story
NoSQL and JavaScript: a Love StoryAlexandre Morgaut
 

Similar to Database Connection Pane (20)

jdbc_presentation.ppt
jdbc_presentation.pptjdbc_presentation.ppt
jdbc_presentation.ppt
 
Lecture13
Lecture13Lecture13
Lecture13
 
Java database connectivity with MYSQL
Java database connectivity with MYSQLJava database connectivity with MYSQL
Java database connectivity with MYSQL
 
I am looking for some assistance with SQLite database. I have tried se.pdf
I am looking for some assistance with SQLite database. I have tried se.pdfI am looking for some assistance with SQLite database. I have tried se.pdf
I am looking for some assistance with SQLite database. I have tried se.pdf
 
Getting Started with React v16
Getting Started with React v16Getting Started with React v16
Getting Started with React v16
 
Tomcat连接池配置方法V2.1
Tomcat连接池配置方法V2.1Tomcat连接池配置方法V2.1
Tomcat连接池配置方法V2.1
 
Java database connecticity steps
Java database connecticity stepsJava database connecticity steps
Java database connecticity steps
 
知っておきたいSpring Batch Tips
知っておきたいSpring Batch Tips知っておきたいSpring Batch Tips
知っておきたいSpring Batch Tips
 
Accessing data with android cursors
Accessing data with android cursorsAccessing data with android cursors
Accessing data with android cursors
 
Accessing data with android cursors
Accessing data with android cursorsAccessing data with android cursors
Accessing data with android cursors
 
Java Web Programming [3/9] : Servlet Advanced
Java Web Programming [3/9] : Servlet AdvancedJava Web Programming [3/9] : Servlet Advanced
Java Web Programming [3/9] : Servlet Advanced
 
Play 2.0
Play 2.0Play 2.0
Play 2.0
 
Deeply Declarative Data Pipelines
Deeply Declarative Data PipelinesDeeply Declarative Data Pipelines
Deeply Declarative Data Pipelines
 
Detail view in distributed technologies
Detail view in distributed technologiesDetail view in distributed technologies
Detail view in distributed technologies
 
React outbox
React outboxReact outbox
React outbox
 
Q
QQ
Q
 
Create a Java FX GUI program that allows the user to insert data int.pdf
Create a Java FX GUI program that allows the user to insert data int.pdfCreate a Java FX GUI program that allows the user to insert data int.pdf
Create a Java FX GUI program that allows the user to insert data int.pdf
 
Lecture17
Lecture17Lecture17
Lecture17
 
NoSQL and JavaScript: a Love Story
NoSQL and JavaScript: a Love StoryNoSQL and JavaScript: a Love Story
NoSQL and JavaScript: a Love Story
 
Intake 37 ef2
Intake 37 ef2Intake 37 ef2
Intake 37 ef2
 

Database Connection Pane

  • 1. DBConnectionPane.java /* * This class defines an extension of BorderPane that allows the user to select * or enter a JDBC driver and a database URL, plus a username and password. * The pane establishes a connection to that driver and URL when its Connect to * DB button is clicked, unless there are errors. If the user later changes the * connection, the previous connection is closed and a new one established; if * an error occurs, the previous connection is closed and the connection * property is set to null. * * The driver input combo box only offers the MySQL driver. Oracle has removed * the JDBC-ODBC bridge driver from Java 8, and the online Oracle database * access doesn't work for me; the page won't load. * * Author: Bill Rutherford * */ import javafx.scene.layout.*; import javafx.scene.control.*; import javafx.geometry.*; import java.sql.*; public class DBConnectionPane extends BorderPane { /** Database connection object */ private Connection connection; // UI input controls private Label lblStatus = new Label(); private ComboBox<String> cboDriver = new ComboBox<>(); private ComboBox<String> cboDatabaseURL = new ComboBox<>(); private TextField tfUsername = new TextField(); private PasswordField pfPassword = new PasswordField(); public DBConnectionPane() { // Set up the combo boxes cboDriver.getItems().add("com.mysql.jdbc.Driver"); cboDriver.setEditable(true); cboDatabaseURL.getItems().addAll("jdbc:mysql://localhost/javabook", "jdbc:mysql://localhost/test"); cboDatabaseURL.setEditable(true); // Create UI HBox labelPane = new HBox(); labelPane.setPadding(new Insets(5, 10, 10, 10)); labelPane.getChildren().add(lblStatus); GridPane inputPane = new GridPane(); inputPane.setPadding(new Insets(0, 10, 0, 10)); inputPane.setHgap(10); inputPane.setVgap(10); inputPane.add(new Label("JDBC Drive"), 0, 0); inputPane.add(cboDriver, 1, 0); inputPane.add(new Label("Database URL"), 0, 1); inputPane.add(cboDatabaseURL, 1, 1); inputPane.add(new Label("Username"), 0, 2); inputPane.add(tfUsername, 1, 2); inputPane.add(new Label("Password"), 0, 3); inputPane.add(pfPassword, 1, 3); Button btConnect = new Button("Connect to DB"); HBox buttonPane = new HBox(); buttonPane.setPadding(new Insets(0, 10, 10, 10)); buttonPane.setAlignment(Pos.CENTER_RIGHT); buttonPane.getChildren().add(btConnect);
  • 2. setTop(labelPane); setCenter(inputPane); setBottom(buttonPane); // Set button event handler btConnect.setOnAction(e -> connectToDB()); } // Create DB connection object and return it in the connection property private void connectToDB() { try { if (connection != null) { // A previous connection was established connection.close(); connection = null; } Class.forName(cboDriver.getValue()); // Load the driver String databaseURL = cboDatabaseURL.getValue(); connection = DriverManager.getConnection(databaseURL, tfUsername.getText(), pfPassword.getText()); lblStatus.setText("Connected to " + databaseURL); } catch (NullPointerException ex) { lblStatus.setText("Please enter a driver name"); } catch (ClassNotFoundException ex) { lblStatus.setText("Invalid driver name, or driver not installed"); } catch (SQLException ex) { if (ex.getMessage().contains("Access denied")) lblStatus.setText("Invalid username/password combination"); else if (ex.getMessage().contains("No suitable driver found")) lblStatus.setText("Invalid database URL"); else if (ex.getMessage().contains("The url cannot be null")) lblStatus.setText("Please enter a database URL"); else if (ex.getMessage().contains("Unknown database")) lblStatus.setText(ex.getMessage()); else { lblStatus.setText("Unexpected error"); ex.printStackTrace(); } } } /** Return connection property */ public Connection getConnection() { return connection; } } TestDBConnectionPane.java /* * This program defines a DBConnectionPane class that extends BorderPane, and * tests it. The test program displays two windows - the test window as the * primary stage, and the DBConnectionPane window off to the left as a secondary * stage. The test window uses the connection defined in the connection window * to obtain and show the tables in the database when its Show Database Tables * button is clicked. * * Author: Bill Rutherford * */
  • 3. import javafx.application.Application; import javafx.scene.Scene; import javafx.stage.Stage; import javafx.geometry.Pos; import javafx.scene.layout.*; import javafx.scene.control.*; import java.sql.*; public class TestDBConnectionPane extends Application { private TextArea taTables = new TextArea(); @Override public void start(Stage primaryStage) { // Create connection pane DBConnectionPane dbPane = new DBConnectionPane(); // Create UI for test window Button btShowTables = new Button("Show Database Tables"); HBox buttonPane = new HBox(10); buttonPane.setAlignment(Pos.CENTER); buttonPane.getChildren().add(btShowTables); taTables.setEditable(false); taTables.setWrapText(true); VBox testPane = new VBox(10); testPane.getChildren().addAll(taTables, buttonPane); // Set button event handler btShowTables.setOnAction(e -> showDatabaseTables(dbPane)); // Set up the test pane in the primary stage and show it Scene testScene = new Scene(testPane, 300, 150); primaryStage.setTitle("Test DBConnectionPane"); primaryStage.setScene(testScene); primaryStage.show(); // Create a secondary stage, set up the connection pane in it, and show // it off to the left of the test window Stage secondaryStage = new Stage(); Scene dbScene = new Scene(dbPane, 320, 210); secondaryStage.setTitle("DB Connection"); secondaryStage.setScene(dbScene); secondaryStage.setX(primaryStage.getX() - 350); secondaryStage.setY(primaryStage.getY() - 30); secondaryStage.show(); } // Obtain and show the table names in the database private void showDatabaseTables(DBConnectionPane dbPane) { Connection connection = dbPane.getConnection(); String tables = ""; try { DatabaseMetaData dbMetaData = connection.getMetaData(); ResultSet rsTables = dbMetaData.getTables(null, null, null, new String[] {"TABLE"}); while (rsTables.next()) tables += (rsTables.getString("TABLE_NAME") + " "); if (tables.equals("")) taTables.setText("No tables in database"); else taTables.setText(tables); }
  • 4. catch (NullPointerException ex) { taTables.setText("Error: No connection established"); } catch (SQLException ex) { taTables.setText("Unexpected error"); ex.printStackTrace(); } } public static void main(String[] args) { launch(args); } }