I am doing some practice with clsql. I want to connect my oracle server hence my connection function is;
(connect '("192.168.2.3" "xe" "username" "password") :database-type :oracle)
when i hit the return, the following error message shows up.
Couldn't load foreign libraries "libclntsh", "oci". (searched *FOREIGN-LIBRARY-SEARCH-PATHS*)
[Condition of type SIMPLE-ERROR]
I have already installed oracle-instantclient11.2-basic-11.2.0.1.0-1.i386.rpm
and define export LD_LIBRARY_PATH=/usr/lib/oracle/11.2/client/lib
So, what else should I do to connect the server?
I was playing with oracle lately and found out that all you need is to put path to libclntsh into /etc/ld.conf.d/oracle.conf
My setup was following( redhat,centos - as root): downloaded from oracle
oracle-instantclient12.1-basic-12.1.0.2.0-1.x86_64.rpm
oracle-instantclient12.1-devel-12.1.0.2.0-1.x86_64.rpm
install via rpm -ivh oracle*.rpm
Create file /etc/ld.so.conf.d/oracle.conf:
/usr/lib/oracle/12.1/client64/lib
then execute ldconfig
Now as clsql-oracle is not in quicklisp, I downloaded and extracted clsql-6.6.2, then
(require "asdf")
(push #P"/opt/jeff/clsql-6.6.2/" asdf:*central-registry*)
(asdf:load-system :clsql-oracle)
(defparameter *some-db* (connect '("127.0.0.1:1521/db1" "SOME_USER_RO" "*******") :database-type :oracle))
and voila, it works
One thing that trips me up with dynamic linking to the Oracle libs (in C/C++ that is), is the fact that the libclntsh.so shared object comes with the version after the so name. So you may need to create a soft link in the same directory, ensuring that the soft link name is just libclntsh.so
Related
I am trying to get RODBC to work on heroku. I have a rails app that calls an R script from RinRuby, which then queries the production database in order to do some analysis. It all works fine on my local Mac, so I thought the best approach was to use the binary compiled on my Max (psqlodbcw.so) into my repo, and reference it in production as well. Unfortunately, when I try to make the connection in production using this connection string:
> library(RODBC)
> dbhandle <- odbcDriverConnect('driver=./psqlodbcw.so;database=nw_server_production;trusted_connection=true;uid=nw_server')
Warning messages:
1: In odbcDriverConnect("driver=./psqlodbcw.so;database=<db_name>;trusted_connection=true;uid=<user>") :
[RODBC] ERROR: state 01000, code 0, message [unixODBC][Driver Manager]Can't open lib './psqlodbcw.so' : file not found
2: In odbcDriverConnect("driver=./psqlodbcw.so;database=<db_name>;trusted_connection=true;uid=<user>?") :
ODBC connection failed
I have seen this error in a similar post online here, but using SQL server instead of postgres. But the accepted answer on that post doesn't explain why the file isn't found, despite being in the app directory. I did follow the same approach and made my own custom buildpack (available here: https://github.com/NovaWulf/r-rodbc-buildpack). I replaced the .so file with the one I compiled on my mac, and simply deleted the .rll file and the code that copies it, since I don't have that file (and hopefully don't need it for psqlodbc?). When I run that buildpack it runs without error on heroku, but then when I reference the .so file copied from the buildpack, I get the same "file not found" error.
Is this happening because the .so file was compiled on the wrong system architecture? I tried compiling psqlodbc on linux, but I do not get a psqlodbcq.so file when I do that (let alone an .rll file). The closest thing I get is a file called libodbcpsqlS.so, which is a setup file, not a driver file.
Could someone please help me understand the best approach to this problem? Why is heroku not seeing the file that is not there? And what is the best solution? Is there a simple way to just download the correct driver file somewhere?
Any help is much appreciated!
Best,
Paul
There is Prometheus Oracle database exporter https://github.com/iamseth/oracledb_exporter
Under Running section, "/path/to/binary -l log.level error -l web.listen-address 9161" is not clear me.
Here I am not getting what is "/path/to/binary" mean, is it oracle client or /usr/bin/ path, or which file I need to replace with? I have RHEL7.3
After setting DATA_SOURCE_NAME is set correctly and running below commman, its throwing error (no such cmd - /path/to/binary)
/path/to/binary -l log.level error -l web.listen-address 9161
Please refer ZIP/clone from location :-https://github.com/iamseth/oracledb_exporter
Oracle database exporter should start and fetch required values/status from oracle database.
In case you're still looking for the answer:
The easiest way is to download the pre-compiled version. Otherwise you will need to compile it yourself: https://github.com/iamseth/oracledb_exporter/releases
Download the version you want e.g. 'oracledb_exporter.0.2.2.linux-amd64.tar.gz' and unzip it.
You will get a folder 'oracledb_exporter.0.2.2.linux-amd64' which conatins two files:
default-metrics.toml
oracledb_exporter
The second one is the one you need to execute:
-> /path_to/oracledb_exporter.0.2.2.linux-amd64/oracledb_exporter log.level error web.listen-address 9161
How fix this error, I use python3.6 and I use Oracle database 11g, I want to connect my python to oracle database, but shows error, how can I fix it?
This is my code:
#importing module
import cx_Oracle
#create a table in oracle database
try:
con = cx_Oracle.connect('db_employees/root#localhost')
#Now execute the sqlquery
cursor = con.cursor()
cursor.execute("insert into employees values(2171114103970002, raden, ceo, 01031997, batam, 001)")
#commit that insert the provided database
con.commit()
except cx_Oracle.DatabaseError as e:
print("There is a problem with Oracle", e)
#by writing finally if any error occurs
#then also we can close the all database operation
finally:
if cursor:
cursor.close()
if con:
con.close()
This is messages error:
C:\Python36>python "D:\testing.py"
There is a problem with Oracle DPI-1047: Cannot locate a 32-bit Oracle Client library: "The specified module could not be found". See https://oracle.github.io/odpi/doc/installation.html#windows for help
Traceback (most recent call last):
File "D:\testing.py", line 20, in <module>
if cursor:
NameError: name 'cursor' is not defined
Here are the installation instructions: Installing cx_Oracle on Windows.
The error is saying you need a 32-bit Oracle client library. You can get one from 32-bit Windows Instant Client (The 64-bit libraries are here if anyone needs them) Any version up to 19c will connect to Oracle DB 11.2. Instructions are at the foot of the page. Make sure you have the correct VS redistributable installed.
Check your path to see if the client is on it, in some cases the path is not set to point the client or contain invalid characters on it and the python library can't access to it.
You can check here a similar issue https://github.com/oracle/python-cx_Oracle/issues/55
I was facing the same issue and here are the steps how I fixed this -
Download latest 64-bit version of oracle basic instantClient from:
https://www.oracle.com/database/technologies/instant-client/winx64-64-downloads.html
In my case I have downloaded - windows.x64-19.10.0.0.0dbru.zip
Unzip the Oracle instantClient and copy all .dll files
Copy these .dll files from Oracle instantclient directory to the python directory
How do I have to install tnsping?
I tried to install oracle-instantclient12.1-basic-12.1.0.2.0-1.x86_64.rpm and I'm able to use some client commands but nog tnsping.
Oracle Instance Client does not include tsnping application. You must run "Oracle Universal Installer" and enable the option for it.
I don't' remember exactly which option you have to set, either it was "Oracle Database Utilities" or "Oracle Net"
Also see McTnsping [link broken] "a Windows stand-alone program which requires no Oracle client". It's portable and doesn't need to be installed.
Usage 1: McTnsping.exe { <tns entry> | <host>:<port> } [<count>]
<tns entry> the net service name in the tnsnames.ora file.
<host>:<port> server name or IP and port (mandatory)
<count> number of times to check target, default is 1.
If whoever will reach the place like me... This is what worked for me:
Instant client Version 12.2.0.1 + sqlplus + tnsping (copied from another server of the same version)
Directory structure and env (as in bash profile):
export ORACLE_BASE=/opt/oracle
export ORACLE_HOME=${ORACLE_BASE}/instant_client122
export PATH=$ORACLE_HOME:$PATH
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME #since all binaries are in $ORACLE_HOME - no bin or lib are present
export TNS_ADMIN=$ORACLE_HOME/network/admin
copy from another server to target:
'tnsping' to $ORACLE_HOME
'$ORACLE_HOME/network/mesg/tnsus.msb' to $ORACLE_HOME/network/mesg
Then put proper values to $TNS_ADMIN/tnsnames.ora and load env variables. After this it should be able to perform 'tnsping' and show proper message as a response.
Here's what I did to copy tnsping over to another machine. In my case, the oracle client is installed at C:\Oracle\product\12.1.0\client_1.
This assumes there's already an Instant Client or similar installed on the destination machine; and that the oracle path and registry keys are set.
(1) Copy tnsping.exe from the source to the destination machine, into client_1\bin.
(2) Copy the following files from client_1\bin to client_1\bin:
oraasmclnt12.dll
oracell12.dll
oraclient12.dll
oraclsce12.dll
oracommon12.dll
oracore12.dll
orageneric12.dll
orahasgen12.dll
oraldapclnt12.dll
oran12.dll
orancds12.dll
orancrypt12.dll
oranhost12.dll
oranl12.dll
oranldap12.dll
oranls12.dll
oranro12.dll
orantcp12.dll
orantns12.dll
oraocr12.dll
oraocrb12.dll
oraocrutl12.dll
oraplp12.dll
orapls12.dll
ORASLAX12.DLL
orasnls12.dll
oraunls12.dll
orauts.dll
oravsn12.dll
oraxml12.dll
orazt12.dll
oraztkg12.dll
This should be about 84.6 MB.
(3) In the client_1 on the destination machine, make a backup of the following files:
oci.dll
orannzsbb12.dll
oraons.dll
orasql12.dll
orawsec12.dll
Now on the source machine, find those files in client_1\bin and copy them to client_1\ (no bin) on the destination machine, overwriting the existing files. (Note: oci.dll is ~330 kb smaller, orasql12.dll is ~300 kb smaller. I'm not sure what's lost, hence the backup).
(4) On the destination machine, create the directory mesg in client_1\Network. Now copy the following file from the source to the destination:
client_1\Network\mesg\tnsus.msb
(5) Open up regedit. Create the following key:
HKEY_LOCAL_MACHINE\SOFTWARE\Oracle\KEY_OraClient12Home1_32bit
(From another machine, it looks like the x64 version is named HKEY_LOCAL_MACHINE\SOFTWARE\Oracle\KEY_OraClient12Home1, but the tnsping program I'm using says it's 64 bit, so ...)
Under the key, create a string named ORACLE_HOME with the value C:\Oracle\product\12.1.0\client_1.
You should be done now ($$$ = redacted):
C:\Users\$$$>tnsping $$$
TNS Ping Utility for 64-bit Windows: Version 12.1.0.2.0 - Production on 03-APR-2
019 08:47:37
Copyright (c) 1997, 2014, Oracle. All rights reserved.
Used parameter files:
C:\Oracle\product\12.1.0\client_1\network\admin\sqlnet.ora
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)
(HOST = $$$)(PORT = $$$))) (CONNECT_DATA = (SERVICE_NAME = $$$
$$$) (SERVER = DEDICATED)))
OK (30 msec)
Troubleshooting
Here's the process I followed, sharing for when these steps invariably fail to work on a later version.
First off, I just copied the tnsping.exe over.
I didn't haphazardly pick the above dlls, as far as I can tell everyone is required. I ran the exe, and it would popup an error, I would copy the dll over and try again:
After a few dlls, you'll run into a different kind of error:
If that happens, fire up process monitor and put a filter in for the ProcessName to contain tnsping and try to run the program again. You should see something like the following. The main thing to notice is that it tries to load (in this example) orawsec12.dll, which succeeds, but then it continues to try to load the dll looking in different paths, and then at the end it triggers werfault and the program ends. I guess it realizes there's some kind of version mismatch and keeps looking for the right version.
The missing registry key will show up like the following in process monitor (operation RegOpenKey, result NAME NOT FOUND):
If the tnsus.msb file is missing, you should see something like the following in process monitor (operation CreateFile, result NAME NOT FOUND):
See bottom for conclusion:
I'm trying to use schemacrawler to diagram a sqlite database. My setup:
OSX 10.8
SchemaCrawler 10.5 downloaded from Here
Java version 1.7.0_45 downloaded from Oracle
sqlite version: 3.7.12 2012-04-03 19:43:07 86b8481be7e76cccc92d14ce762d21bfb69504af
I'm in the directory where I installed schemacrawler, and using this command line:
stebro$ java -classpath lib/*:. schemacrawler.tools.sqlite.Main /Library/Application\ Support/MyApp/Data/MyApp.db -command="select count(*) from myTable" -infolevel=maximum
SchemaCrawler 10.5
Copyright (c) 2000-2013, Sualeh Fatehi.
SchemaCrawler is a database schema discovery and comprehension tool.
You can search for database schema objects using regular expressions,
and output the schema and data in a readable text format. You can find
potential schema design issues with lint. The output serves for
database documentation is designed to be diff-ed against other database
schemas. SchemaCrawler also generates schema diagrams.
password:
java.sql.SQLException: Could not connect to database, for user null
at schemacrawler.schemacrawler.BaseDatabaseConnectionOptions.getConnection(BaseDatabaseConnectionOptions.java:93)
at schemacrawler.schemacrawler.BaseDatabaseConnectionOptions.getConnection(BaseDatabaseConnectionOptions.java:70)
at schemacrawler.tools.commandline.SchemaCrawlerCommandLine.execute(SchemaCrawlerCommandLine.java:173)
at schemacrawler.tools.commandline.SchemaCrawlerMain.main(SchemaCrawlerMain.java:93)
at schemacrawler.tools.commandline.SchemaCrawlerMain.main(SchemaCrawlerMain.java:52)
at schemacrawler.tools.sqlite.Main.main(Main.java:43)
Caused by: java.lang.IllegalArgumentException: Insufficient parameters for database connection URL: missing [database]
at schemacrawler.schemacrawler.DatabaseConfigConnectionOptions.getConnectionUrl(DatabaseConfigConnectionOptions.java:73)
at schemacrawler.schemacrawler.BaseDatabaseConnectionOptions.getConnection(BaseDatabaseConnectionOptions.java:89)
... 5 more
If I specify -password, I get the same error, and specifying various values for -user does the same. Sqlite requires no user/password - why is the jdbc or schemacrawler asking me for one?
Addendum:
Here is a specific series of commands that creates a simple database then attempts to diagram it with schemacrawler:
bash-3.2$ sqlite3 MyApp.db
sqlite3 MyApp.db
SQLite version 3.7.12 2012-04-03 19:43:07
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> create table smbtest(col1 integer, col2 integer);
create table smbtest(col1 integer, col2 integer);
sqlite> ^D
bash-3.2$ ~/bin/sunjava -classpath lib/*:. schemacrawler.tools.sqlite.Main -database=MyApp.db -infolevel=maximum -command=graph -outputformat=pdf -outputfile=myapp.pdf
SchemaCrawler 10.5
Copyright (c) 2000-2013, Sualeh Fatehi.
SchemaCrawler is a database schema discovery and comprehension tool.
You can search for database schema objects using regular expressions,
and output the schema and data in a readable text format. You can find
potential schema design issues with lint. The output serves for
database documentation is designed to be diff-ed against other database
schemas. SchemaCrawler also generates schema diagrams.
password:
Graphviz was not available to create the requested graph. Please reinstall
Graphviz, and make it available on the system PATH. Meanwhile, a .dot text file
has been created instead. This .dot file can be opened in any Graphviz file
viewer.
java.io.IOException: Cannot run program "dot": error=2, No such file or directory
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1041)
at schemacrawler.tools.integration.graph.ProcessExecutor.execute(ProcessExecutor.java:124)
at schemacrawler.tools.integration.graph.GraphGenerator.generateDiagram(GraphGenerator.java:87)
at schemacrawler.tools.integration.graph.GraphExecutable.executeOn(GraphExecutable.java:123)
at schemacrawler.tools.executable.SchemaCrawlerExecutable.executeOn(SchemaCrawlerExecutable.java:87)
at schemacrawler.tools.executable.BaseExecutable.execute(BaseExecutable.java:77)
at schemacrawler.tools.commandline.SchemaCrawlerCommandLine.execute(SchemaCrawlerCommandLine.java:176)
at schemacrawler.tools.commandline.SchemaCrawlerMain.main(SchemaCrawlerMain.java:93)
at schemacrawler.tools.commandline.SchemaCrawlerMain.main(SchemaCrawlerMain.java:52)
at schemacrawler.tools.sqlite.Main.main(Main.java:43)
Caused by: java.io.IOException: error=2, No such file or directory
at java.lang.UNIXProcess.forkAndExec(Native Method)
at java.lang.UNIXProcess.<init>(UNIXProcess.java:135)
at java.lang.ProcessImpl.start(ProcessImpl.java:130)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1022)
... 9 more
Final conclusion:
The problem lay in the fact that the path to my db had a space in it; no combination of backslashing, double or single quotes, or both resolved the issue. Running the command from the same directory as my db file did the trick. The space issue may be due to my not understanding the right escape sequences to use in bash - I may have to double-escape the spaces if schemacrawler is spawning other processes using my name as part of the command line.
However, the app did continue to ask for my password, but just pressing enter allowed it to continue successfully.
Steve,
You need to specify the database like this:
"-database=/Library/Application Support/MyApp/Data/MyApp.db"
Notice the double-quotes to allow for the space in the path to the database file, and the -database command-line switch. I also removed the back-slash, since the whole switch in enclosed in double-quotes.
For help on the command-line, simply run:
java -classpath lib/*:. schemacrawler.tools.sqlite.Main
Sualeh Fatehi, SchemaCrawler
Generating DB Schema ER Diagram using SchemaCrawler We can visualize our DB schema using SchemaCrawler Download the latest package from here:
https://github.com/sualeh/SchemaCrawler/releases/
Copy _schemacrawler folder and rename it to schemacrawler to another location and add the directory path of the same to PATH Use GraphViz to create schema diagram http://sualeh.github.io/SchemaCrawler/diagramming.html
Cd into schemacrawler directory and run ./schemacrawler.sh(on mac and ubuntu env) with option as mentioned below.
You can run sample command to get the schema diagram in the form of png image for postgre db:
./schemacrawler.sh -command graph -outputformat png -outputfile=dh_er.png -loglevel=CONFIG -server=postgresql -host=localhost -port=5432 -database=testdb -user=testuser -password=testpass -infolevel=standard
To include/exclude some tables you need to define configuration
in schemacrawler.config.properties as example:
schemacrawler.table.pattern.include=.*askbot_activityauditstatus |.*askbot_anonymousanswer|.*askbot_anonymousquestion |.*askbot_askwidget|.*askbot_badgedata|.*askbot_bulktagsubscription |.*askbot_bulktagsubscription_groups|.*askbot_bulktagsubscription_tags
schemacrawler.table.pattern.exclude is the key. value of the same is the JAVA regex pattern
Note: If you are facing "SERVICE: Cannot run program "dot": error=2, No such file or directory" issue...
Please install below(for mac only):
Install the app : brew install graphviz
I don't think you are specifying -classpath correctly. I think you need a wrapper shell script around that command to expand each .jar in lib so that it's separated with : characters:
#!/bin/sh
classpath="."
for j in lib/*.jar
do
classpath=$classpath:$j
done
java -classpath $classpath schemacrawler.tools.sqlite.Main /Library/Application\ Support/MyApp/Data/MyApp.db -command="select count(*) from myTable" -infolevel=maximum
Just a stab-in-the-dark but that's the way I've always done it. Obviously this is more complicated if non-jar classpaths have to be included as well...