I am using following simple code to connect to database and I am getting error as ORA-24399 which says invalid number of connections specified. I have googled enough but not clue. This is a CPP program.
Following is code Snippet:
try
{
Environment *env = Environment::createEnvironment(Environment::DEFAULT);
Connection *con= env->createConnection("test","test","testdb");
}
catch(SQLException ex)
{
cout<<ex.getMessage().c_str();
}
P.S Using SQL Plus I am able to connect to the database where this code is being run. There are no issues there. Only through program there is a failure seen.
P.P.S Tried using connectionpool as well but still no luck...
Looking at your error, it seems that the problem is somewhere else in your code: you should fix the parameters (related to connection numbers) in the call to OCIConnectionPoolCreate.
Related
It's just plain luck my program is so simple, so I eventually found out what causes the mysterious log message. My program log looks like this:
Debugging starts
failed to start
Debugging has finished
Which happens after:
camera = new QCamera(QCameraInfo::defaultCamera());
// see http://omg-it.works/how-to-grab-video-frames-directly-from-qcamera/
camera->setViewfinder(frameGrabber = new CameraFrameGrabber());
camera->start();
The start() method causes this message in console. Now the meaning of the message is obvious, what it's not very helpful. What steps should I take to troubleshoot it?
Reasons for this might differ, but in my case it was simply because I provided invalid QCameraInfo. The culprit is that QCameraInfo::defaultCamera() might return invalid value if Qt fails to detect any cameras on your system, which unfortunately happens even if cameras are present.
My application is an server application that accepts some predefined commands from user and displays respective output that is taken from XML files present at the server end.
For parsing XML file I am using xerces-c library version 3.1.2 from apache. The application works fine when ran manually on a terminal.
But I wanted to run the application through telnet on a network so that I can give inputs to the application via telnet and receive output on a remote system too. For this I used inetd super server and added below line in inetd.conf:
vterm stream tcp nowait root /path/to/my/binary/vterm vterm
Then added below line in /etc/services to make it listen on port 5000
vterm 5000/tcp
After that when I tried to connect to my application I used to get below message:
msatyam#sabayon ~/programming/cpp/xml $ telnet localhost 5000
Trying ::1...
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
Connection closed by foreign host.
When the above connection closed message came I thought I have not configured properly my application with inetd. So, I replaced my binary with a simple binary which didn't used any extra libraries. Just simple cin's and cout's, which worked perfectly fine.
Then it turns out to be something wrong with my application so for this I put whole lot of cout's to identify what actually is happening. With this I found that one of the xerces-c XML parsing library function is returning NULL and with this NULL reference I am trying to call a function in line below which is making my application dump as soon as it starts.
But the thing is the same function is working fine when I run my application manually on a terminal. Full application is bit big so I have created a demo code which reproduces the problem. Here is my code:
#include <xercesc/util/PlatformUtils.hpp>
#include <xercesc/parsers/XercesDOMParser.hpp>
#include <xercesc/dom/DOMDocument.hpp>
#include <xercesc/dom/DOMElement.hpp>
#include <iostream>
using namespace std;
using namespace xercesc;
int main()
{
try
{
// init xerces XML Parser library
XMLPlatformUtils::Initialize();
}
catch (const XMLException& ex)
{
cerr << ex.getMessage() << endl;
}
// parse a XML file
XercesDOMParser* parser = new XercesDOMParser();
try
{
parser->parse("sample.xml");
}
catch (const XMLException& ex)
{
cerr << ex.getMessage() << endl;
}
// get the document reference
DOMDocument* doc = parser->getDocument();
if (doc == NULL)
{
cout <<"Doc is NULL" << endl;
}
// else do stuff further
// like get root element
DOMElement* root = doc->getDocumentElement();
// print node name
string name = XMLString::transcode(root->getTagName());
cout << "Name: " << name << endl;
XMLPlatformUtils::Terminate();
return 0;
}
The above code when compiled and ran manually does not go into that if condition which says "Doc is NULL" and successfully prints the root element tag name, but when I run this application behind inetd and when I telnet to it I am able to see "Doc is NULL" statement and after that same message "Connection closed by foreign host." as my application would be probably dumping.
I am a bit out of brains now as I am not sure where to look exactly. As same code works when ran manually but not through inetd.
So, I am thinking do we need to take some special attention while executing processes via inetd that uses shared libraries, like here I am using xerces-c shared library for XML parsing.
Or What else could be possibly wrong with my understanding or my code.
How come the same library functions works perfectly fine when application ran manually and not working when ran via inetd?
I tried the same using xinetd instead of inetd but same results.
As you have proven yourself, the working directory is / when you start your tool via inetd. But your XML file is not in the root directory of your system. You can hardwire the full path into your application. A better solution would be to pass the location of your file(s) as a parameter.
I'm trying get the proxy settings for my computer automatically.
I've set up a local server and I've uploaded a .pac file (which I can access from my browser) and I've set the link to it in the Internet Explorer connection settings, in the "address" field and checked "Use automatic configuration script".
My code is the following:
int main()
{
LPWSTR str = NULL;
if (!WinHttpDetectAutoProxyConfigUrl(WINHTTP_AUTO_DETECT_TYPE_DHCP | WINHTTP_AUTO_DETECT_TYPE_DNS_A, &str))
{
printf("%d\n", GetLastError());
}
if(str)
GlobalFree(str);
return 0;
}
The function always fails and GetLastError returns 12180 (ERROR_WINHTTP_AUTODETECTION_FAILED)
What am I doing wrong?
From https://developer.appcelerator.com/question/120622/errorwinhttpautodetectionfailed:
This error message is not necessarily a problem and can be ignored if you are using direct connection. you get this error if you are having direct connection. to check that and get more info, you can use the following commands:
cd windows\system32
netsh winhttp help
— answered 4 years ago by Nick G
From your comment I gather that this was indeed the reason you were getting this error, so I'm posting it as an answer.
I am helping a friend with his bachelor thesis project. It is a program that calculates bending moments for various materials. One of the extra requirements that the client desires is database functionality to store and retrieve various pieces of data being used in the program.
The program is a forms application written in managed C++. I jumped on board to help with writing the database functionality. I am using MySQL Server 5.5 and the MySQL Connector/C++ to bridge the program and the database. Everything has been going pretty well and all the functionality we need works just fine, but only in debug. As soon as we put the program into release mode there is undefined behavior occurring at runtime. Below is the function that is used to open a connection to the database:
try
{
m_driver = get_driver_instance();
m_conn = m_driver->connect(m_dbHost, m_dbUser, m_dbPwd);
m_conn->setSchema(m_dbSchema);
}
catch(sql::SQLException &e)
{
int a = e.getErrorCode();
MessageBoxA(NULL, e.what(), "DB Error", MB_OK);
}
The values passed into the connect function are all std::string. In debug mode the connection is made with no issues. In release mode an exception is caught after the connect function is called, and displays the message "Unknown MySQL Server Host '####' (0)" where the #### is always some garbage text. I also notice that in the output window another exception is being thrown, this one is the type System.Runtime.InteropServices.SEHException.
I have been doing some research and have seen numerous cases of this exception on many forums (and here on stack exchange) but no one seems to be having this issue with the MySQL connector. My assumption is that the memory is being corrupted because the program is mixed mode, with the main program code being written in Managed C++ and my database helper code being in native C++ (as required by the connector).
Is there something I can change in my code to try and fix this issue to that the strings aren't being corrupted at run time. I have tried many different hacks to try and solve the problem but nothing has worked.
Thanks,
Tom
Update: I am now seeing this error in debug mode. I added code to retrieve values from the database and populate some text boxes on the form. The code is as follows:
// Populate the form with material details
String^ selectedMaterial = (String^)(comboBox1->SelectedItem);
string selectedMaterial_ = "";
MarshalString(selectedMaterial, selectedMaterial_);
sql::ResultSet* results = dbHelper.GetData("matname", selectedMaterial_);
if (results->rowsCount() == 1)
{
// Outdim
string outdim_ = "";
outdim_ = results->getString("outdim");
String^ outdim = gcnew String(outdim_.c_str());
textBox1->Text = outdim;
}
else
{
// !!!! Duplicate materials in list
}
When it tries to read outdim from the result set the SEHException is thrown, and the only other piece of information given is that it was thrown in an external component.
Update 2: I ran Application Verifier against the debug executable and then launched the program from VS2010. However the form window never loads so somewhere along the line the program must be getting halted. Strangely there is absolutely no information in the log files in Application Verifier. I also tried with the release version and I didnt get any useful information from that either.
What could be cause of QAbstractSocket::UnknownSocketError when using QTcpSocket?
CODE
I'm getting this error code with the following code:
this->connect(socket, SIGNAL(socketError(QAbstractSocket::SocketError)), SLOT(handleSocketError(QAbstractSocket::SocketError)));
...
void MyClass::handleSocketError(QAbstractSocket::SocketError error)
{
qDebug() << error;
}
MORE INFO
The QTcpSocket is trying to connect to some remote host. And it fails with mentioned error code.
If you read the code, you'll see that this error means exactly what it says: "something bad happened and I don't know why". There had to be exceptions, of course:
The socket is not connected to a server and you try to write to it (src/network/socket/qabstractsocket.cpp on line 2025)
An SSL error occurred (src/network/ssl/qsslsocket_openssl.cpp in a lot of places)
In both situations the errorString is set to an appropriate message.
Possibly you called the error() function when there is no error.
Looking for AbstractSocketError in the Qt sources gives quite some hits. Maybe fire up a debugger and look into the backtrace when you get the error() signal. Possibly an exotic error condition occured in the underlying socket engine (which is a Qt internal class).
Does remote host require ssl connection? It may be problem if your Qt copy can't load libssl. I had same problem (UnkownSocketError) when Qt couldn't find libssl