My problem is that I am trying to make a connection using Java (using Eclipse) to a local database. I don't want to use a remote database because I dont want to setup a server and also because my aplication doesn't need a remote DB.
I dont'have Microsoft Access, so I created the database using LibreOffice. What I know is that LibreOffice is the interface that allows you to create a database, and it can be set up using another database infrastructure like Oracle, MySQL, SQL Server, etc.
I decided to download the driver HSQLDB.jar and I installed it in Eclipse.
The following code shows you my example:
String db="C:\\Users\\Alberto\\Documents\\Peluqueria.odb";
try {
// Cargamos el controlador JDBC
Class.forName("org.hsqldb.jdbcDriver");
} catch (Exception ex){
System.err.println("Se pa producido un error al cargar el controlador JDBC");
return;
}
// Nos conectamos a la base de datos creándola en caso de que no exista
Connection conn = DriverManager.getConnection("jdbc:hsqldb:file:"+db,"sa","");
Statement statement=conn.createStatement();
ResultSet rs=statement.executeQuery("SELECT * FROM TB_Servicios");
while (rs.next()){
System.out.println(rs.getString(1));
}
The Error Exception i get is:
java.sql.SQLSyntaxErrorException: usuario no tiene privilegios suficientes o objeto no encontrado: TB_SERVICIOS
at org.hsqldb.jdbc.JDBCUtil.sqlException(Unknown Source)
at org.hsqldb.jdbc.JDBCUtil.sqlException(Unknown Source)
at org.hsqldb.jdbc.JDBCStatement.fetchResult(Unknown Source)
at org.hsqldb.jdbc.JDBCStatement.executeQuery(Unknown Source)
at Formularios.VentantaTabla.<init>(VentantaTabla.java:69)
at Formularios.VentantaTabla$1.run(VentantaTabla.java:31)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$200(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Caused by: org.hsqldb.HsqlException: usuario no tiene privilegios suficientes o
objeto no encontrado: TB_SERVICIOS
at org.hsqldb.error.Error.error(Unknown Source)
at org.hsqldb.error.Error.error(Unknown Source)
at org.hsqldb.SchemaManager.getTable(Unknown Source)
at org.hsqldb.ParserDQL.readTableName(Unknown Source)
at org.hsqldb.ParserDQL.readTableOrSubquery(Unknown Source)
at org.hsqldb.ParserDQL.XreadTableReference(Unknown Source)
at org.hsqldb.ParserDQL.XreadFromClause(Unknown Source)
at org.hsqldb.ParserDQL.XreadTableExpression(Unknown Source)
at org.hsqldb.ParserDQL.XreadQuerySpecification(Unknown Source)
at org.hsqldb.ParserDQL.XreadSimpleTable(Unknown Source)
at org.hsqldb.ParserDQL.XreadQueryPrimary(Unknown Source)
at org.hsqldb.ParserDQL.XreadQueryTerm(Unknown Source)
at org.hsqldb.ParserDQL.XreadQueryExpressionBody(Unknown Source)
at org.hsqldb.ParserDQL.XreadQueryExpression(Unknown Source)
at org.hsqldb.ParserDQL.compileCursorSpecification(Unknown Source)
at org.hsqldb.ParserCommand.compilePart(Unknown Source)
at org.hsqldb.ParserCommand.compileStatements(Unknown Source)
at org.hsqldb.Session.executeDirectStatement(Unknown Source)
at org.hsqldb.Session.execute(Unknown Source)
... 18 more
Can anybody help me?