use derby ij against an existing database
Frecuentes
Visto 998 veces
2
While I'm having some trouble installing and setting up derby, I do have partial success:
root@dur:~/apache-james-3.0-beta4/var/store/derby#
root@dur:~/apache-james-3.0-beta4/var/store/derby# ll
total 36
drwxr-xr-x 5 root root 4096 Aug 23 16:46 ./
drwxr-xr-x 5 501 staff 4096 Aug 23 02:07 ../
-rw-r--r-- 1 root root 4 Aug 23 02:07 dbex.lck
-rw-r--r-- 1 root root 38 Aug 23 02:07 db.lck
-rw-r--r-- 1 root root 187 Aug 23 16:46 derby.log
drwxr-xr-x 2 root root 4096 Aug 23 02:07 log/
drwxr-xr-x 2 root root 4096 Aug 23 02:07 seg0/
-rw-r--r-- 1 root root 868 Aug 23 02:07 service.properties
drwxr-xr-x 2 root root 4096 Aug 23 02:07 tmp/
root@dur:~/apache-james-3.0-beta4/var/store/derby#
root@dur:~/apache-james-3.0-beta4/var/store/derby# java org.apache.derby.tools.ij
ij version 10.9
ij> quit;
root@dur:~/apache-james-3.0-beta4/var/store/derby#
How do I now query this particular database?
2 Respuestas
2
A full example, using Derby and Squirrel, presuming you have a Derby database already installed on the system:
- Instale SQL ardilla dentro
$HOME/bin/squirrel
- Instale Derby de Apache dentro
$HOME/bin/db-derby
- Run Squirrel (
cd $HOME/bin/squirrel ; ./squirrel-sql.sh
) - Presione Drivers to open the Drivers panel.
- Haga doble clic en Apache Derby Embedded.
- Presione Extra Class Path.
- Presione Añada.
- Elija una
$DERBY_HOME/lib/derby.jar
. - Kit URL de ejemplo to the database path (e.g., the directory containing
seg0
). - Presione OK para guardar.
At this point the Apache Derby Embedded icon should no longer have a red X.
Entonces:
- Haga clic en el Alias .
- Kit Nombre to: DerbyDB
- Asegurar Destornillador is set to: Apache Derby Embedded
- Verificar el Enlance is pointing to the directory containing
seg0
. - Presione OK (no username or password needed?).
- Presione Conéctate.
The database is now connected and you should see the schemas.
Entonces:
- Prensa Ctrl + n to display a new SQL editor window, or click the SQL .
- Tipo:
SELECT * FROM SYS.SYSTABLES
- Click the Running human icon (or press Ctrl + Shift + Enter) to execute the query.
You can now execute SQL statements against the Derby database.
Note: This does not technically answer the question, as this answer does not explain how to use the interactive command-line interface (ij
). The answer proposes a viable alternative to querying the database using Squirrel's graphical interface.
Respondido 29 Jul 13, 18:07
1
I still don't know how to really query the db itself, but it's fairly simple to connect, aparentemente:
root@dur:~/apache-james-3.0-beta4/var/store/derby#
root@dur:~/apache-james-3.0-beta4/var/store/derby# pwd
/root/apache-james-3.0-beta4/var/store/derby
root@dur:~/apache-james-3.0-beta4/var/store/derby#
root@dur:~/apache-james-3.0-beta4/var/store/derby# ll
total 24
drwxr-xr-x 4 root root 4096 Aug 23 18:24 ./
drwxr-xr-x 5 501 staff 4096 Aug 23 02:07 ../
-rw-r--r-- 1 root root 1092 Aug 23 18:24 derby.log
drwxr-xr-x 2 root root 4096 Aug 23 02:07 log/
drwxr-xr-x 2 root root 4096 Aug 23 02:07 seg0/
-rw-r--r-- 1 root root 868 Aug 23 02:07 service.properties
root@dur:~/apache-james-3.0-beta4/var/store/derby#
root@dur:~/apache-james-3.0-beta4/var/store/derby# java org.apache.derby.tools.ij
ij version 10.9
ij> connect 'jdbc:derby:/root/apache-james-3.0-beta4/var/store/derby';
ij>
;
ij> show schema;
ERROR 42X01: Syntax error: Encountered "show" at line 1, column 1.
Issue the 'help' command for general information on IJ command syntax.
Any unrecognized commands are treated as potential SQL commands and executed directly.
Consult your DBMS server reference documentation for details of the SQL syntax supported by your server.
ij>
;
ij> show schemas;
TABLE_SCHEM
------------------------------
APP
NULLID
SQLJ
SYS
SYSCAT
SYSCS_DIAG
SYSCS_UTIL
SYSFUN
SYSIBM
SYSPROC
SYSSTAT
11 rows selected
ij> show tables;
TABLE_SCHEM |TABLE_NAME |REMARKS
------------------------------------------------------------------------
SYS |SYSALIASES |
SYS |SYSCHECKS |
SYS |SYSCOLPERMS |
SYS |SYSCOLUMNS |
SYS |SYSCONGLOMERATES |
SYS |SYSCONSTRAINTS |
SYS |SYSDEPENDS |
SYS |SYSFILES |
SYS |SYSFOREIGNKEYS |
SYS |SYSKEYS |
SYS |SYSPERMS |
SYS |SYSROLES |
SYS |SYSROUTINEPERMS |
SYS |SYSSCHEMAS |
SYS |SYSSEQUENCES |
SYS |SYSSTATEMENTS |
SYS |SYSSTATISTICS |
SYS |SYSTABLEPERMS |
SYS |SYSTABLES |
SYS |SYSTRIGGERS |
SYS |SYSVIEWS |
SYSIBM |SYSDUMMY1 |
APP |JAMES_DOMAIN |
APP |JAMES_MAIL |
APP |JAMES_MAILBOX |
APP |JAMES_MAIL_PROPERTY |
APP |JAMES_MAIL_USERFLAG |
APP |JAMES_RECIPIENT_REWRITE |
APP |JAMES_SUBSCRIPTION |
APP |JAMES_USER |
APP |OPENJPA_SEQUENCE_TABLE |
31 rows selected
ij> quit;
root@dur:~/apache-james-3.0-beta4/var/store/derby#
contestado el 23 de mayo de 17 a las 13:05
No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas database ubuntu command-line-interface derby or haz tu propia pregunta.
an example query would be: select * from app.james_mailbox; - bryan pendleton