I am connecting sybase by using DSN + SQLAnywhere.. But not able to find the driver. Please suggest me suitable Driver.
Program:
Class.forName("com.sybase.jdbc4.jdbc.SybDriver");
Connection connection=DriverManager.getConnection("jdbc:SQLAnywhere:MYDB");
error
Unable to get a connection from Sybase database No suitable driver found for jdbc:SQLAnywhere:SHRDB java.sql.SQLException:No suitable driver found for jdbc:SQLAnywhere:MYDB
if you are using the sajdbc4.jar, try this:
try {
Class.forName("sybase.jdbc4.sqlanywhere.IDriver");
Connection con = DriverManager.getConnection("jdbc:sqlanywhere:dsn=*;uid=*;pwd=*");
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
}
for older versions (SQLAnywhere 11) this driver should work: "sybase.jdbc.sqlanywhere.IDriver"
Related
Have an app that has been running without issue (or so Ive been told) for months, but as of a few weeks ago started failing. Looking at the logs, I see a lot of these errors
EXCEPTION: Error intializing Firefox driver. Error message: 'Cannot
start the driver service on http://localhost:52022/';
WebDriverException stack: 'OpenQA.Selenium.WebDriverException: Cannot
start the driver service on http://localhost:52022/ at
OpenQA.Selenium.DriverService.Start() at
OpenQA.Selenium.Remote.DriverServiceCommandExecutor.Execute(Command
commandToExecute) at
OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String
driverCommandToExecute, Dictionary`2 parameters) at
OpenQA.Selenium.Remote.RemoteWebDriver.StartSession(ICapabilities
desiredCapabilities) at
OpenQA.Selenium.Remote.RemoteWebDriver..ctor(ICommandExecutor
commandExecutor, ICapabilities desiredCapabilities) at ... ... .
The project is a console app that is using the Selenium project to try to connect to an external website but it seems it is having trouble just starting up. The code where this exception is caught is below.
this._logger = logger;
this._processLog = new List<string>();
FirefoxProfile profile = null;
FirefoxOptions options = null;
profile = new FirefoxProfile();
profile.SetPreference("browser.download.folderList", 2);
profile.SetPreference("browser.download.dir", downloadPath);
profile.SetPreference("browser.download.manager.alertOnEXEOpen", false);
profile.SetPreference("browser.download.manager.focusWhenStarting", false);
profile.SetPreference("browser.download.manager.closeWhenDone", true);
profile.SetPreference("browser.download.manager.showAlertOnComplete", false);
profile.SetPreference("browser.helperApps.alwaysAsk.force", false);
profile.SetPreference("browser.helperApps.neverAsk.saveToDisk", "application/json,text/csv");
profile.SetPreference("browser.download.manager.useWindow", false);
profile.SetPreference("browser.download.panel.shown", false);
options = new FirefoxOptions();
options.AddArguments("-headless");
options.AddArgument("no-sandbox");
options.Profile = profile;
try
{
this._driver = new FirefoxDriver(driverPath, options, TimeSpan.FromSeconds(180));
}
catch (WebDriverException ex)
{
string message = string.Format("Error intializing Firefox driver. Error message: '{0}'; WebDriverException stack: '{1}' ",
ex.Message, ex.ToString());
result.ProcessLog.Add(new LogMessage(LogLevel.EXCEPTION, message));
throw ex;
}
catch(Exception ex)
{
string message = string.Format("Error intializing Firefox driver. Error message: '{0}'; Exception stack: '{1}' ",
ex.Message, ex.ToString());
result.ProcessLog.Add(new LogMessage(LogLevel.EXCEPTION, message));
throw ex;
}
The computer where this process runs has the latest version of Firefox installed, however, the FireFox Selenium driver looks dated. Could there be a dependency issue?
I'm using TDengine-server-2.1.2.0 on Linux. There is a TDengine client on Windows:TDengine-client-2.1.2.0-Windows-x64.
com.taosdata.jdbc
taos-jdbcdriver
2.0.30
I'm using JDBC-JNI to connect TDengine.
private static void init() throws Exception {
Class.forName("com.taosdata.jdbc.TSDBDriver");
String jdbcUrl = "jdbc:TAOS://tdengine-4:6030/test?
user=zzss&password=dfsdfasd";
Connection conn =
DriverManager.getConnection(jdbcUrl);
}
Then we met the exception.
Exception in thread "main" java.sql.SQLException: JNI
ERROR (2354): JNI connection is NULL
at com.taosdata.jdbc.TSDBError.createSQLException(TSDBError.java:72)
at com.taosdata.jdbc.TSDBError.createSQLException(TSDBError.java:56)
at com.taosdata.jdbc.TSDBJNIConnector.connect(TSDBJNIConnector.java:88)
at com.taosdata.jdbc.TSDBConnection.connect(TSDBConnection.java:47)
at com.taosdata.jdbc.TSDBConnection.(TSDBConnection.java:33)
at com.taosdata.jdbc.TSDBDriver.connect(TSDBDriver.java:128)
at java.sql.DriverManager.getConnection(DriverManager.java:664)
at java.sql.DriverManager.getConnection(DriverManager.java:270)
at com.cz.tdengine.config.Test.init(Test.java:34)
at com.cz.tdengine.config.Test.main(Test.java:23)
JDBC-RESTful style is OK. So I'm wondering what may be the problem.
I've implemented JSend NSCA to send passive checks to Nagios like below:
public static void main(String[] args) {
NagiosSettings nagiosSettings = new NagiosSettingsBuilder()
.withNagiosHost("192.168.1.20")
.withPassword("nagiosadmin")
.withPort(5666)
.withConnectionTimeout(5000)
.withResponseTimeout(15000)
.create();
NagiosPassiveCheckSender sender = new NagiosPassiveCheckSender(
nagiosSettings);
MessagePayload payload = new MessagePayloadBuilder()
.withHostname("localhost")
.withLevel(Level.CRITICAL)
.withServiceName("Test Service Name")
.withMessage("Test Message")
.create();
try {
sender.send(payload);
} catch (NagiosException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
But I had the following errors:
java.net.ConnectException: Connection refused
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:351)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:213)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:200)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:432)
at java.net.Socket.connect(Socket.java:529)
at com.googlecode.jsendnsca.core.NagiosPassiveCheckSender.send(NagiosPassiveCheckSender.java:69)
at app.QuickStart.main(QuickStart.java:29)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
Nagios Username and password are: nagiosadmin/nagiosadmin.
The IPserver for nagios is 192.168.1.20.
Thank you.
Can you try a quick telnet test
From your command line run
telnet 192.168.1.20 5666
If the response is
Connecting To 192.168.1.20...Could not open connection to the host, on port 5666: Connect failed
Then the NSCA daemon is either
not running
running on a different port other than 5666
BTW, Im the project lead for jsendnsca. In future, you can post questions like this at
https://code.google.com/p/jsendnsca/issues/list
and create an issue
How do I set a port number for mysql connection in Agile Toolkit? The mysql in my local machine is running in a different port 3307, how should be my connection configuration look like?
I tried the following but it did not work,
$config['dsn']='mysql://atk:password#localhost:3307/atk';
I am getting the following error when I try a db test,
C:\xampp\htdocs\atk4.1.2\atk4\lib\DBlite/mysql.php:40 [2] mysql_pconnect() [function.mysql-pconnect]: [2002] No connection could be made because the target machine actively refused it. (trying to connect via tcp://localhost:3306)
C:\xampp\htdocs\atk4.1.2\atk4\lib\DBlite/mysql.php:40 [2] mysql_pconnect() [function.mysql-pconnect]: No connection could be made because the target machine actively refused it.
SQLException
Database connection failed
MySQL error:
No connection could be made because the target machine actively refused it.
C:\xampp\htdocs\atk4.1.2\atk4\lib\BaseException.php:37
Stack trace:
C:\xampp\htdocs\atk4.1.2\atk4\lib/BaseException.php :37 SQLException BaseException->collectBasicData(Null, 1, 0)
C:\xampp\htdocs\atk4.1.2\atk4\lib/SQLException.php :45 SQLException BaseException->__construct("<p>Database connection failed</p><b>MySQL error:</b> <div style='border: 1px solid black'><font color=red>No connection could be...", Null, 1)
C:\xampp\htdocs\atk4.1.2\atk4\lib/DBlite.php :359 SQLException SQLException->__construct(Null, "Database connection failed")
C:\xampp\htdocs\atk4.1.2\atk4\lib/DBlite.php :101 gift_project DBlite->fatal("Database connection failed", True)
C:\xampp\htdocs\atk4.1.2\atk4\lib/ApiCLI.php :276 gift_project DBlite->connect(Array(7))
C:\xampp\htdocs\atk4.1.2\page/dbtest.php :7 gift_project ApiCLI->dbConnect()
C:\xampp\htdocs\atk4.1.2\atk4\lib/AbstractObject.php :129 gift_project_dbtest page_dbtest->init()
C:\xampp\htdocs\atk4.1.2\atk4\lib/ApiFrontend.php :90 gift_project AbstractObject->add("page_dbtest", "dbtest", "Content")
C:\xampp\htdocs\atk4.1.2\atk4\lib/ApiWeb.php :305 gift_project ApiFrontend->layout_Content()
C:\xampp\htdocs\atk4.1.2\atk4\lib/ApiWeb.php :297 gift_project ApiWeb->addLayout("Content")
C:\xampp\htdocs\atk4.1.2\atk4\lib/ApiWeb.php :182 gift_project ApiWeb->initLayout()
C:\xampp\htdocs\atk4.1.2/index.php :15 gift_project ApiWeb->main()
Solution : The following type of configuration works,
$config['dsn']=array('type'=>'mysql',
'hostspec'=>'localhost:3307',
'username'=>'atk',
'password'=>'password',
'database'=>'atk',
'charset'=>'utf-8');
try the following
$config['dsn']=array('type'=>'mysql','username'=>'atk',
'host'=>'localhost','database'=>'atk','password'=>'password',
'port'=>3307,'charset'=>'utf-8');
I am facing problem while using JRO in winform application to compact access database on windows server 2008 R2 (64bit) server. I followed below steps:
Configuration of Development PC:
OS : Windows XP Professional Ver: 2002 (SP3) 32Bit
MSOffice 2003 Installed: Yes
Visual Studio: 2010 Premium
.Net framework: 4.0.30319
Two winform App with below code are created:
Application 1: For compacting Access 2007 DB
Target Platform is set to x86 and Added reference of Microsoft Jet and Replication Objects 2.6 Library
Config file:
<?xml version="1.0"?>
<configuration>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0,Profile=Client"/></startup>
<appSettings>
<add key="SourceDB" value="Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\Test\Test2007.accdb;Jet OLEDB:Engine Type=5"/>
<add key="DestDB" value="Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\Test\Test2007BK.accdb;Jet OLEDB:Engine Type=5"/>
<add key="AppDB" value="Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\Test\Test2007.accdb;" />
</appSettings>
</configuration>
Code:
string SrcDBName = ConfigurationManager.AppSettings["SourceDB"];
string DestDBName = ConfigurationManager.AppSettings["DestDB"];
int ReturnCode = 0;
JRO.JetEngine objJRO = null;
try
{
MessageBox.Show("Start Compact");
objJRO = new JRO.JetEngine();
objJRO.CompactDatabase(SrcDBName, DestDBName);
MessageBox.Show("End Compact");
}
catch (Exception ex)
{
MessageBox.Show("Error in Compact");
ReturnCode = -1;
StackTrace STrace = new StackTrace(ex, true);
StackFrame StkFrame = STrace.GetFrame(STrace.FrameCount - 1);
string Disp_Msg = "Message:\t" + ex.Message + Environment.NewLine;
Disp_Msg += "Error Date:\t" + DateTime.Now.ToString("dddd, MMM d yyyy HH:mm:ss");
//MessageBox.Show(Disp_Msg, "Compact Utility", MessageBoxButtons.OK, MessageBoxIcon.Error);
File.AppendAllText(Path.GetDirectoryName(Application.ExecutablePath) + #"\CompactErr.txt", Disp_Msg + Environment.NewLine + "Stack Trace:\t" + ex.StackTrace + Environment.NewLine + Environment.NewLine);
}
finally
{
Marshal.ReleaseComObject(objJRO);
objJRO = null;
}
Application 2: For Testing Connection with Access 2007
private void Form1_Load(object sender, EventArgs e)
{
try
{
//Connection Test
MessageBox.Show("Start DBConn");
TestConn();
MessageBox.Show("End DBConn");
}
catch (Exception ex)
{
MessageBox.Show("Error in Conn Opening");
string Disp_Msg = "Message:\t" + ex.Message + Environment.NewLine;
Disp_Msg += "Error Date:\t" + DateTime.Now.ToString("dddd, MMM d yyyy HH:mm:ss");
File.AppendAllText(Path.GetDirectoryName(Application.ExecutablePath) + #"\CompactErr.txt", Disp_Msg + Environment.NewLine + "Stack Trace:\t" + ex.StackTrace + Environment.NewLine + Environment.NewLine);
}
}
public void TestConn()
{
string strConnectionString = ConfigurationManager.AppSettings["AppDB"];
DbConnection objConnection;
DbProviderFactory objFactory = OleDbFactory.Instance;
objConnection = objFactory.CreateConnection();
objConnection.ConnectionString = strConnectionString;
objConnection.Open();
objConnection.Close();
}
Now above 2 exe are deployed on Win2008 Server:
Server Details:
Windows Server 2008 R2 (SP1) - 64bit
NO MSOffice
NO Visual Studio
Installed: Microsoft Office Access Database Engine 2010
Case 1: when Access DB Engine 2010 (64bit) is installed:
Link: http://www.microsoft.com/download/en/details.aspx?id=13255
Connection to Access 2007 (Test2007.accdb) is CORRECTLY DONE
Compact of DB using JRO NOT WORKED
Error Message while executing Step 2:
Message:Class not registered
Stack Trace:at JRO.IJetEngine.CompactDatabase(String SourceConnection, String Destconnection)
at CompactUtility.Program.Main(String[] args)
Case 2: when Access DB Engine 2007 is installed:
Link: http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=23734
Connection to Access 2007 (Test2007.accdb) is NOT DONE
Compact of DB using JRO CORRECTLY WORKED
Error Message while executing Step 1:
Message: The 'Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine.
Any Suggestion/help will be highly appreciated to solve both working on windows server 2008 (64bit) server.
Also refereed below links but not helpful:
Microsoft.ACE.OLEDB.12.0 provider is not registered
Thanks,
Shah
I know, it's an old question but still, This link did help me with the second issue.
If i remember correctly, the problem stems from a 64bit issue with the engine.
Adding the Component into Visual Studio should fix this behaviour.