Call to undefined function oci_connect() in Heroku app - java

I have a problem in my code. I need to push code to Heroku (running on Ubuntu 14.04); my code is PHP and Oracle database. oci_connect() works perfectly in localhost and connect successfully to the Oracle database but when I push to Heroku it's returning "Call to undefined function oci_connect()". I tried to install bitbucket-heroku like Ruby and Java, but nothing has worked for me yet.
Image: Heroku error app
This is my link in Heroku: https://serene-anchorage-79470.herokuapp.com/home.php?language=en
My config code:
$conn = oci_connect('username', 'pass','(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST =myhost )(PORT =port )) (CONNECT_DATA = (SID =sid )))');
if($conn)
{
echo "Successfully connected to Oracle.\n";
}
else
{
$err = OCIError();
echo "Connection failed." . $err[text];
}

The reason you are getting this error is because you are missing the OCI8 PHP extension which is needed in order to connect to Oracle database using PHP.
If your Oracle database is not hosted on the same server, you will also need to install Oracle Instant Client on the linux server.

Related

Docker : Running java app with database integratedsecurity = true fails with "no sqljdbc_auth in java.library.path"

I am running a java app in docker 'openjdk:8-jdk-alpine' container which connects to sql server with integratedsecurity = true and it fails with "no sqljdbc_auth in java.library.path" , is there a way I can resolve this without using sql authentication?

Connect J2ME to HTTPS Server

I have written a J2ME application using WTK 2.5.2 with JDK 1.8.0_361 and JDK
1.5.0_22.
The following code snippet is used to connect to an HTTP server and it works as expected.
try{
http = (HttpConnection)Connector.open(url);
http.setRequestMethod(HttpConnection.POST);
OutputStream os = http.openOutputStream();
String params = "XXXXXXXX";
os.write(params.getBytes());
respCode = http.getResponseCode();
}catch(Exception e){
System.out.println(e);
}
However, when trying to connect to an HTTPS site, it throws one of these two errors:
Google:
java.io.IOException: Bad record type (21) or version (3.1)
Wikipedia:
java.io.IOException: Alert (2,40)
I have tried using HttpsConnection and switching to another WTK and JRE version.
Exporting the application to device shows another error:
java.io.IOException: Alert (2, 70)
Thanks in advance.

BlueCove with Bluez chucks "Can not open SDP session. [2] No such file or directory"

I am trying to write a simple Bluetooth server that accepts an connection from my HeartRate-Device (bluetooth LE) but it always raises an exception
javax.bluetooth.ServiceRegistrationException: Can not open SDP session. [2] No such file or directory
at com.intel.bluetooth.BluetoothStackBlueZ.openSDPSessionImpl(Native Method) ~[bluecove-gpl-2.1.1-SNAPSHOT-63.jar:2.1.1-SNAPSHOT]
at com.intel.bluetooth.BluetoothStackBlueZ.getSDPSession(BluetoothStackBlueZ.java:518) ~[bluecove-gpl-2.1.1-SNAPSHOT-63.jar:2.1.1-SNAPSHOT]
at com.intel.bluetooth.BluetoothStackBlueZ.registerSDPRecord(BluetoothStackBlueZ.java:543) ~[bluecove-gpl-2.1.1-SNAPSHOT-63.jar:2.1.1-SNAPSHOT]
at com.intel.bluetooth.BluetoothStackBlueZ.rfServerOpen(BluetoothStackBlueZ.java:607) ~[bluecove-gpl-2.1.1-SNAPSHOT-63.jar:2.1.1-SNAPSHOT]
at com.intel.bluetooth.BluetoothRFCommConnectionNotifier.<init>(BluetoothRFCommConnectionNotifier.java:42) ~[bluecove-2.1.1-SNAPSHOT-63.jar:2.1.1-SNAPSHOT]
at com.intel.bluetooth.MicroeditionConnector.openImpl(MicroeditionConnector.java:389) ~[bluecove-2.1.1-SNAPSHOT-63.jar:2.1.1-SNAPSHOT]
at com.intel.bluetooth.MicroeditionConnector.open(MicroeditionConnector.java:156) ~[bluecove-2.1.1-SNAPSHOT-63.jar:2.1.1-SNAPSHOT]
at javax.microedition.io.Connector.open(Connector.java:83) ~[bluecove-2.1.1-SNAPSHOT-63.jar:2.1.1-SNAPSHOT]
at com.mmazurcz.bluetoothserver.WaitThread.waitForConnection(WaitThread.java:39) [classes/:na]
at com.mmazurcz.bluetoothserver.WaitThread.run(WaitThread.java:60) [classes/:na]
at java.lang.Thread.run(Thread.java:745) [na:1.8.0_45]
I am running my code on an Arch Linux machine with kernel "4.0.5-1-ARCH #1 SMP PREEMPT".
Java is OpenJDK at version 1.8.0_45 and Bluecove is at version 2.1.1-SNAPSHOT-63. I've got the following BlueZ artifacts installed:
bluez 5.30-1
bluez-firmware 1.2-8
bluez-libs 5.30-1
bluez-utils 5.30-1
The Bluetooth dongle I am using is up and running and I can scan for my heart-rate device using hcitool -i hci0 lescan. I am also running my code as the root user.
So, here is the piece of code that brings me trouble:
StreamConnectionNotifier notifier;
StreamConnection connection = null;
// setup the server to listen for connection
try {
local = LocalDevice.getLocalDevice();
log.info("Set up local device with BT address: " + local.getBluetoothAddress());
local.setDiscoverable(DiscoveryAgent.GIAC);
log.info("Set local device to GIAC discovery mode");
UUID uuid = new UUID("1101", true);
String url = "btspp://localhost:" + uuid.toString() + ";name=RemoteBluetooth";
notifier = (StreamConnectionNotifier) Connector.open(url);
} catch (Exception e) {
log.error("Exception in WaitThread.waitForConnection", e);
return;
}
Any ideas?
First: I know this is a rather old post, but I got here quite often through Google and I finally got it working on my machine.
To got it working we need to start the bluetooth daemon with the -C (or --compat) option. This is done by making the following change:
Open a terminal and enter
sudo nano /etc/systemd/system/bluetooth.target.wants/bluetooth.service
then change line
ExecStart=/usr/lib/bluetooth/bluetoothd
to
ExecStart=/usr/lib/bluetooth/bluetoothd -C
(simply adding the -C option)
Now you need to restart the system daemons:
sudo systemctl daemon-reload
And finally restart the Bluetooth service:
sudo systemctl restart bluetooth
I found this solution here: RaspberryPi Forum: Bluetooth RFCOMM - Jessie
Hope I could still help someone!
I had the same problem for few days now, I followed Cyphargs instruction but then I got new problem, it says permission denied instead of saying no such file or directory, then i found the magic solution on Arch Linux forum :
chmod 777 /var/run/sdp # this line has done the magic

Accessing a local MySQL instance in your GAE development environment for java using eclipse

I am new to Google App Engine environment. We are starting a project where we are using Google Cloud SQL. For testing purpose we need to setup a local MySQL instance.
I have tried searching for the answer, but I didn't find any that helped me.
If I was to summarize my question, I am trying access a local MySQL instance in my GAE development environment using JAVA in Eclipse.
You have to add the MySQL connector in you App Engine SDK folder.
You can find the connector there: http://dev.mysql.com/downloads/connector/j/.
Then, you have to place it in this folder: appengine-java-sdk\lib\impl
Then you have to run a local version of MySQL (for example using EasyPHP).
Here is a sample of the code that you could use to connect to your database (singleton) :
public static Connection getInstance() throws Exception {
if (connection != null && !connection.isClosed()) {
return connection;
}
if (isLocalTesting) {
//MySQL
String url = "jdbc:mysql://127.0.0.1:3306/YOUR_DB_NAME";
connection = DriverManager.getConnection(url, "root", "");
} else {
// Google Cloud SQL
DriverManager.registerDriver(new AppEngineDriver());
connection = DriverManager.getConnection("jdbc:google:rdbms://" + instanceName + "/NAME_DB");
}
return connection;
}
And lastly:
You have to include the MySQL library in your build path as well: http://prntscr.com/124jwm
I use Eclipse Juno and install Google App Engine SDK and plugin. There is configuration for development mysql and google cloud SQL instance. its automaticaly go to your local when development and go to cloud SQL when you deploy it.

weblogic jmx tomcata php/java bridge and getting t3 protocol working

I have PHP and the PHP/Java bridge set up on Windows and Tomcat 7.0. All is OK there.
However, I am trying to write a php file with java calls to connect to my Weblogic server installed on my Windows 7 machine to play around with adding/deleting users/groups etc.
This is what I followed: http://docs.oracle.com/cd/E13222_01/wls/docs90/jmx/accessWLS.html I also looked at this one http://weblogic-wonders.com/weblogic/2009/10/11/creating-users-in-weblogic-server-embedded-ldap-programatically/ (but for the second one I get an error on the java:comp/env/jmx/runtime line)
However, I cannot get my set up to recognize "t3" protocols to connect to my weblogic. the weird thing is I can connect via a t3 protocol using jython in a separate standalone script and to the console that way.
There is a section in first link above to make sure that wljmxclient.jar is added to the classpath. I set up a classpath to add that. I even use PHP to exec Weblogic's setWLSenv.cmd right before the connection to my Weblogic server is made to set my classpath . . . it shows the jar file in question being added. Still won't work. I then copied the jar file to the JavaBirde/WEB-INF/lib folder. Still wont' work.
I did try IIOP protocol but then I started down an new path of errors where "not bound in this context" was indicated. I tried switching between the 3 Mservers mentioned in the Oracle doc link above. No luck there either.
I see that others have run into this "t3 protocol not supported" message but I don't see any solutions.
Here is my code:
<?php
require_once("java/Java.inc");
$output=exec("C:\Oracle\Middleware\wlserver_12.1\server\bin\setWLSenv.cmd");
$protocol = "t3";
$hostname = "localhost";
$port="7001";
$jndiroot="/jndi/";
$mserver="weblogic.management.mbeanservers.domainruntime";
$united = $jndiroot.$mserver;
$serviceURL = new java("javax.management.remote.JMXServiceURL",$protocol, $hostname, $port,$united);
$h = new java("java.util.Hashtable");
$h->put("javax.naming.Context.SECURITY_PRINCIPAL", "myUID");
$h->put("javax.naming.Context.SECURITY_CREDENTIALS", "myPWD");
$h->put("javax.management.remote.JMXConnectorFactory.PROTOCOL_PROVIDER_PACKAGES",
"weblogic.management.remote");
$connector = new java("javax.management.remote.JMXConnectorFactory");
$connector->connect($serviceURL,$h);
?>
This is how I FINALLY connected to my Weblogic:
1) I installed Tomcat 7.0 zip file instead of the installer and set it up manually. In my
setenv.bat file it looks like:
set CATALINA_HOME=C:\Program Files (x86)\Apache Software Foundation\apache-tomcat-7.0.34
set CATALINA_BASE=C:\Program Files (x86)\Apache Software Foundation\apache-tomcat-7.0.34
set JAVA_HOME=C:\Program Files (x86)\Java\jdk1.7.0_09
set JRE_HOME=C:\Program Files (x86)\Java\jdk1.7.0_09\jre
set JAVA_OPTS=-Djava.ext.dirs=C:\Oracle\Middleware\wlserver_12.1\server\lib
set CLASSPATH=.;C:\Oracle\Middleware\wlserver_12.1\server\lib\wljmxclient.jar
exit /b 0
2) I enabled IIOP protocol in weblogic through the weblogic console and added a userid/password which I used in num 3 for the userID/password
3) My php script on Tomcat 7 with the PHP/Java Bridge (not the JMXServerURL . . . nowhere did I find that you had to use "rmi" as the protocol")
$serviceURL = new java("javax.management.remote.JMXServiceURL","rmi","localhost","7001","/jndi/iiop://localhost:7001/weblogic.management.mbeanservers.edit");
//"service:jmx:iiop://localhost:7001/jndi/weblogic.management.mbeanservers.edit");
$env = new java("java.util.Hashtable");
$env->put("javax.management.remote.JMXConnectorFactory.PROTOCOL_PROVIDER_PACKAGES","weblogic.management.remote");
$env->put("javax.naming.Context.SECURITY_PRINCIPAL", "myuserID");
$env->put("javax.naming.Context.SECURITY_CREDENTIALS", "mypassword");
$jmxCon = java("javax.management.remote.JMXConnectorFactory")->newJMXConnector($serviceURL, $env);
$jmxCon->connect();
$connection = $jmxCon->getMBeanServerConnection();
$mbeans = $connection->queryNames(null,null);
foreach($mbeans as $key=>$value) {
echo $key. "=". $value;
}
It connected and printed out all the mbeans for my admin server and my two managed servers that I created for testing.

Categories