1
I have a problem that’s making me miserable. Here’s the thing:
I have a database and have my program in java everything connected, already created the jar file and all.
But the problem is that the program only runs on the machine perfectly on the machine in which the database is installed, I would like to know how to ensure that the application will continue to save data without however having the database installed.
Basically I need to know somehow how to carry the database along with my app. package.ie.work.;
import java.sql.Connection; import java.sql.Drivermanager; import java.sql.Resultset; import java.sql.Sqlexception; import java.sql.Statement;
public class Connexaooracle {
private String NomeDoUsuario;
private String Senha;
private String Caminho;
private final String host = "localhost";
private final String servico = "xe";
private final String PortaDeEntrada = "1521";
public Connection Connexao;
public ConnexaoOracle(String nome, String Senha) {
setNomeDoUsuario(nome);;
setSenha(Senha);
setCaminho();
}
public void setNomeDoUsuario(String Nome){
this.NomeDoUsuario =Nome;
}
public void setSenha(String senha){
this.Senha = senha;
}
private void setCaminho() {
Caminho = "jdbc:oracle:thin:@"+host + ":" + PortaDeEntrada + ":" + servico;
}
public String getSenha()
{
return this.Senha;
}
public String getNomeDoUsuario() {
return NomeDoUsuario;
}
public String getCaminho() {
return Caminho;
}
public boolean Connectar()
{
boolean vereficadorDeConexao = false;
try {
Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
Connexao = DriverManager.getConnection(getCaminho(), getNomeDoUsuario(), getSenha());
vereficadorDeConexao = true;
} catch (InstantiationException | IllegalAccessException
| ClassNotFoundException | SQLException e) {
vereficadorDeConexao = false;
}
return vereficadorDeConexao;
}
public ResultSet ExecutarComandoSql(String Comando)
{
ResultSet Resultados = null ;
try {
Statement Comandosql = Connexao.createStatement();
Resultados = Comandosql.executeQuery(Comando.toUpperCase());
} catch (SQLException e) {
System.out.println(e.getMessage());
}
return Resultados;
}
public void commit()
{
String Comando = "commit";
ExecutarComandoSql(Comando );
}
public void rollback()
{
String Comando = "rollback";
ExecutarComandoSql(Comando );
}
public boolean Disconnectar()
{
boolean vereficadorDeDesconexao = false;
try {
Connexao.commit();
Connexao.close();
} catch (SQLException e) {
}
vereficadorDeDesconexao = true;
return vereficadorDeDesconexao;
}
}
Using which database? Is a desktop application using swing? Add more details to the question.
– user28595
Enter the code or database configuration file.
– adelmo00