Help me with the HSQLDB and NetBeans.
Please, did someone there already create an Java aplication using HSQLDB?
I must configure the NetBeans to use with hsqldb and create a standalone database but I stop in a lot of troubles.
Let's start:
Im my NetBeans project I create two folders: "db" and 'lib" ...
So, inside of the folder "lib" I've put the file "hsqldb.jar".
So, in the File Menu of my project I select the properties of my project. In the link LIBRARIES of COMPILE option I click Add JAR/Folder. So I select the hsqldb.jar of the lib folder. After this NetBeans recognizes the hsqldb.jar.....
So, in RUNTIME I select Database/Drives I click Add Driver....
Again I select the hsqldb.jar from the "lib" folder.
The new Drive HSQLDB is created... I click on it and select Connect Using... and the DatabaseConnection screen is shown. In database URL I put: jdbc:hsqldb:pathofmydatabase
pathofmydatabase is the folder "db"
User I put "sa" and a blank password...
Remember that I create a standalone database with hsqldb saved inside "db" folder...
That's my code:
import javax.swing.*;
import java.sql.*;
public class TelaPrincipal {
JFrame mainTela = new JFrame("Principal.");
Connection conexao;
Statement sentenca;
ResultSet resultadoConsulta;
String consulta1 = "SELECT id_cliente, nome_cliente, telefone_cliente FROM clientes";
int clienteId;
String clienteNome;
String clienteTelefone;
JTextField idText = new JTextField(4);
JTextField nomeText = new JTextField(35);
JTextField telefoneText = new JTextField(8);
JPanel camposPanel = new JPanel();
public TelaPrincipal() {
mainTela.setExtendedState(JFrame.MAXIMIZED_BOTH);
mainTela.setVisible(true);
mainTela.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
camposPanel.add(idText);
camposPanel.add(nomeText);
camposPanel.add(telefoneText);
mainTela.add(camposPanel);
try {
Class.forName("hsqldb.org.jdbc.Driver");
conexao = DriverManager.getConnection("jdbc:hsqldb:file:/database/clientes", "sa", "");
sentenca = conexao.createStatement();
resultadoConsulta = sentenca.executeQuery(consulta1);
while(resultadoConsulta.next()) {
clienteId = resultadoConsulta.getInt("id_cliente");
clienteNome = resultadoConsulta.getString("nome_cliente");
clienteTelefone = resultadoConsulta.getString("telefone_cliente");
idText.setText(String.valueOf(clienteId));
nomeText.setText(clienteNome);
telefoneText.setText(clienteTelefone);
}
conexao.close();
}
catch(ClassNotFoundException cnfe) { cnfe.printStackTrace(); }
catch(SQLException e) { e.printStackTrace(); }
}
public static void main(String[] args) {
TelaPrincipal tp = new TelaPrincipal();
}
}
------------------------------------------------------------------------------------------------
There's a lot of errors like:
package javax.servlet does not exist
package javax.servlet.http does not exist
and a lot of servel.something tha do not exist...
Why servelets erros if my database is standalone saved in disc?
Does have anything about the hsqldb.org, packages ?
Do I need to configure more things on NetBeans, or change configurations I've made so far?
Something's going terrible wrong and I don't know why...
I need professional help!
Anyone?
Thanks.