For those who are willing to read a bit, (skip to end for short version):
I am trying to connect my java app to a remote oracle database. with no luck I am using Mac 10.7.5 with IntelliJ Idea 12, java version "1.6.0_51" 64-bit. I have been trying to get this work all day with no success. I also was not able to use the 'DataSource' view in IntelliJ because of a missing shared dylib missing in java.library.path. I suspect the two issues are related.
I tried installing Oracle Instant Client 64-bit (including the jdbc files), copied the dylibs to /usr/lib/java and this got me close to solving the "DataSource" view issue with a different error:
java.lang.RuntimeException: java.rmi.UnmarshalException: Error unmarshaling return header; nested exception is:
java.io.EOFException
in RemoteUtil$RemoteInvocationHandler.invoke(RemoteUtil.java:219)
at com.sun.proxy.$Proxy115.connect(Unknown Source)
in LocalDataSource.getConnection(LocalDataSource.java:158)
Caused by: java.rmi.UnmarshalException: Error unmarshaling return header; nested exception is:
java.io.EOFException
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:209)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:142)
at java.rmi.server.RemoteObjectInvocationHandler.invokeRemoteMethod(RemoteObjectInvocationHandler.java:178)
at java.rmi.server.RemoteObjectInvocationHandler.invoke(RemoteObjectInvocationHandler.java:132)
at com.sun.proxy.$Proxy114.connect(Unknown Source)
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)
in RemoteUtil$RemoteInvocationHandler.invoke(RemoteUtil.java:211)
... 21 more
Caused by: java.io.EOFException
at java.io.DataInputStream.readByte(DataInputStream.java:250)
at sun.rmi.transport.StreamRemoteCall.executeCal
So the journey continued and I tried using the 32bit version of the ojdbc .dylibs and .jars but then I ran into 'wrong architecture'when trying to connect to oracle db using IntelliJ's DataSource view.
I would like to keep everything consistent by using 32-bit since most of my apps use libraries that require 32-bit JVM.
tl;dr 'ers:
-Cannot connect to oracle db through IntelliJ Idea 12 DataSource view nor connect through java app using JDBC
-BackGround Info: Mac OSX 10.7.5, Java 1.6.0_51 64-bit, IntelliJ Idea 12, Remote Oracle 11G DB
-Tried both 32-bit and 64-bit versions of Oracle Instant Client with jdbc files, no luck
Any suggestions will be greatly appreciated!
Thank you
Additional Notes: I cannot connect through sqlplus either; i get the error ORA-21561: OID generation failed. Search results only point to fixing the /etc/hosts file which does not make sense for me since the db server is on a remote server and I am connecting using a TNS entry in /etc/tnsnames.ora
===UPDATE 1===
I made some progress on connecting through the java code. Using this code:
Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
Connection conn = DriverManager.getConnection("jdbc:oracle:thin:#hostname:port/service_name", "user", "password");
but received the error:
java.sql.SQLRecoverableException: IO Error: The Network Adapter could not establish the connection
I CAN connect using this exact piece of code on my work machine through eclipse ide but not on my Mac laptop.
For Intellij/DataGrip 2018 DB connection via TNS I got
[08006][17002] IO Error: Invalid connection string format, a valid format is: "host:port:sid"
I find the problem in Oracle driver version: 11.2.0.4
I get "Test Connection > Succesful" using version 12.1.0.2
I can only encourage you to use the oracle thin jdbc client. There must be a very specific reason not to. With that you will likely have NO problems.
Related
i keep on getting the following error when ever i try to run my code to check connection between java code and db.
java.sql.SQLException: No suitable driver found for jdbc:sqlserver://192.168.1.100
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at StoredProcedure.main(StoredProcedure.java:19)
There's not really enough information here to help you. Check out this question for a good example on how to pose your question, and possibly find an answer.
Its' showing No suitable driver found. Check your jdk compatible driver version with sql server.
Check system requirements here
Both jdk 7 and jdk 8 compatible jar file
For 3 days now, I have been trying to install glassfish 4.1 on eclipse Luna version 4.4.1. I first installed the plugin from eclipse marketplace then added it in my runtime using jdk 8. I also made jdk my default since eclipse default uses jre. I have to point out that I have been been using glassfish on netbeans and tomcat on eclipse but I decided to play around with glassfish on eclipse. Every information I got on the internet didn't fix my issue.
Below is the error I got in the console. Right now, this is driving me nuts so I have decided to come to you for direction.
Thanks
Launching GlassFish on Felix platform
ERROR: Unable to create cache directory: C:\Program Files\glassfish-4.1\glassfish\domains\domain1\osgi-cache\felix
ERROR: Error creating bundle cache. (java.lang.RuntimeException: Unable to create cache directory.)
java.lang.RuntimeException: Unable to create cache directory.
at org.apache.felix.framework.cache.BundleCache.<init>(BundleCache.java:131)
at org.apache.felix.framework.Felix.init(Felix.java:640)
at com.sun.enterprise.glassfish.bootstrap.osgi.OSGiFrameworkLauncher$1.run(OSGiFrameworkLauncher.java:88)
Exception in thread "Thread-1" java.lang.RuntimeException: org.osgi.framework.BundleException: Error creating bundle cache.
at com.sun.enterprise.glassfish.bootstrap.osgi.OSGiFrameworkLauncher$1.run(OSGiFrameworkLauncher.java:90)
Caused by: org.osgi.framework.BundleException: Error creating bundle cache.
at org.apache.felix.framework.Felix.init(Felix.java:645)
at com.sun.enterprise.glassfish.bootstrap.osgi.OSGiFrameworkLauncher$1.run(OSGiFrameworkLauncher.java:88)
Caused by: java.lang.RuntimeException: Unable to create cache directory.
at org.apache.felix.framework.cache.BundleCache.<init>(BundleCache.java:131)
at org.apache.felix.framework.Felix.init(Felix.java:640)
... 1 more
Exception in thread "main" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at com.sun.enterprise.glassfish.bootstrap.GlassFishMain.main(GlassFishMain.java:97)
at com.sun.enterprise.glassfish.bootstrap.ASMain.main(ASMain.java:54)
Caused by: org.glassfish.embeddable.GlassFishException: java.lang.NullPointerException
at com.sun.enterprise.glassfish.bootstrap.osgi.OSGiGlassFishRuntimeBuilder.build(OSGiGlassFishRuntimeBuilder.java:170)
at org.glassfish.embeddable.GlassFishRuntime._bootstrap(GlassFishRuntime.java:157)
at org.glassfish.embeddable.GlassFishRuntime.bootstrap(GlassFishRuntime.java:110)
at com.sun.enterprise.glassfish.bootstrap.GlassFishMain$Launcher.launch(GlassFishMain.java:112)
... 6 more
Caused by: java.lang.NullPointerException
at com.sun.enterprise.glassfish.bootstrap.osgi.OSGiGlassFishRuntimeBuilder.newFramework(OSGiGlassFishRuntimeBuilder.java:241)
at com.sun.enterprise.glassfish.bootstrap.osgi.OSGiGlassFishRuntimeBuilder.build(OSGiGlassFishRuntimeBuilder.java:135)
... 9 more
Error stopping framework: java.lang.NullPointerException
java.lang.NullPointerException
at com.sun.enterprise.glassfish.bootstrap.GlassFishMain$Launcher$1.run(GlassFishMain.java:203)
Java HotSpot(TM) Client VM warning: ignoring option MaxPermSize=192m; support was removed in 8.0
Run Eclipse or any other IDE you use in Administrator mode.
Works for me.
I think your comment deserves to be posted as the main answer but I have been trying to mark your comment as answer but I wash't able to. So I decided to post post your comment here and then back it up with my own experience.
Answer by unwichtich:
I guess this is a similar problem. The cause may be that you have installed Glassfish in c:\Program Files. You can try to move your Glassfish installation to a directory where your normal user account has full access rights but you then have to change the path to the Glassfish installation in Eclipse.
My own experience:
Turns out that all the problems I had with the glassfish server (including exit code 1 error) was because glassfish could not handle folder names with spaces in it. So I moved the glassfish-4.1 folder from C:\Program File\glassfish-4.1.. path to C:\ glassfish-4.1.. It wiped all my tears away. This is really important in eclipse and netbeans IDEs (if you are installing the netbeans that does not come with a glassfish bundled zip).
I had the same problem and fixed it by installing Glassfish under C:\ instead of C:\Program Files. Try that.
use JDk 7 instead of JDK 8 am also faced the same issue i just changed to jdk7 its working now.
I am using H2 database in client-server mode. Server is running with version 1.3.175 and client with 1.3.168.
Everything seems working fine, but I get an exception executing some queries:
org.h2.jdbc.JdbcSQLException: General error: "java.lang.NullPointerException" [50000-175]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:332)
at org.h2.message.DbException.get(DbException.java:161)
at org.h2.message.DbException.convert(DbException.java:284)
at org.h2.server.TcpServerThread.sendError(TcpServerThread.java:218)
at org.h2.server.TcpServerThread.run(TcpServerThread.java:158)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NullPointerException
at org.h2.expression.Function.getCost(Function.java:2391)
at org.h2.expression.CompareLike.getCost(CompareLike.java:417)
at org.h2.expression.ConditionAndOr.optimize(ConditionAndOr.java:133)
at org.h2.command.dml.Select.prepare(Select.java:813)
at org.h2.command.Parser.prepareCommand(Parser.java:240)
at org.h2.engine.Session.prepareLocal(Session.java:436)
at org.h2.server.TcpServerThread.process(TcpServerThread.java:260)
at org.h2.server.TcpServerThread.run(TcpServerThread.java:156)
... 1 more
at org.h2.engine.SessionRemote.done(SessionRemote.java:567)
at org.h2.command.CommandRemote.prepare(CommandRemote.java:67)
at org.h2.command.CommandRemote.<init>(CommandRemote.java:46)
at org.h2.engine.SessionRemote.prepareCommand(SessionRemote.java:439)
at org.h2.jdbc.JdbcConnection.prepareCommand(JdbcConnection.java:1109)
at org.h2.jdbc.JdbcPreparedStatement.<init>(JdbcPreparedStatement.java:74)
at org.h2.jdbc.JdbcConnection.prepareStatement(JdbcConnection.java:264)
Thanks for help.
This is a bug in this version of the database engine, which was fixed in revision 5437 of the trunk.
You can either:
go back to the previous version (1.3.174) which should not have this bug,
use the latest nightly build where it should be fixed,
download the latest source code and built the database yourself, or
wait for the next version of H2.
I am using windows server 2003 on VM vare on which I have my database on MS SQL Server 2008 . Now when I used jdbc driver to connect my java code with database I am getting following exception. Kindly give some solution .
Exception in thread "main" java.lang.UnsatisfiedLinkError: com.microsoft.sqlserver.jdbc.AuthenticationJNI.SNISecGenClientContext([B[I[BI[B[I[ZLjava/lang/String;ILjava/lang/String;Ljava/lang/String;Ljava/util/logging/Logger;)I
at com.microsoft.sqlserver.jdbc.AuthenticationJNI.SNISecGenClientContext(Native Method)
at com.microsoft.sqlserver.jdbc.AuthenticationJNI.GenerateClientContext(AuthenticationJNI.java:80)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.sendLogon(SQLServerConnection.java:2691)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.logon(SQLServerConnection.java:2234)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.access$000(SQLServerConnection.java:41)
at com.microsoft.sqlserver.jdbc.SQLServerConnection$LogonCommand.doExecute(SQLServerConnection.java:2220)
at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:5696)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:1715)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:1326)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:991)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:827)
at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:1012)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at test.jdbcdemo.main(jdbcdemo.java:24)
You have enabled integratedSecurity. This means that the sqljdbc_auth.dll needs to be on the library path of the jvm.
Most likely you do not have this library on your path, it is the wrong version or the wrong variant (x86 <> x64 <> IA64).
An old question but I had this issue today. I don't know the first thing about Java but for me the fix was to copy Microsoft's JDBC driver to Java's ext folder.
sqljdbc41.jar needs to be copied to C:\[path to java installation]\Java\jre7\lib\ext\
Make sure you pick the right version (x86 or x64).
Also for Integrated Security I needed to make a reference to auth when starting my application.
-Djava.library.path=C:\[Path to Microsoft JDBC Driver 4.1 for SQLServer]\sqljdbc_4.1\enu\auth\x86
I had the same exception when starting SpringBatch with an JdbcBatchItemWriter writing to MS SQL Server 2008.
Sqljdbc_auth.dll was on the library path. It turned out that I was running my SpringBatch application in Eclipse with JRE 1.6. I solved this by running it with JRE 1.7 (Eclipse JRE-Tab in Run-Configurations).
I am trying to deploy an application that was developed in MyEclipse using Tomcat (originally 5.5 but works with 7) to our demo server (Sun Java Web Server 7). Unfortunately all of the people that had designed the application have left the company. So, here is what I know:
1) The application works as-is in MyEclipse on Tomcat
2) The application was successfully deployed to Sun Java Web Server in the past (presumably with the same build)
3) I can connect to the database from the server with sqldeveloper
4) The application uses: Java EE 5 and Spring framework
Application settings:
driver: oracle.jdbc.driver.OracleDriver
url jdbc:oracle:thin#xx.xx.x.xx:service
Here is the only error I am getting. I get a lot of warnings before and after though:
warning: CORE3283: stderr: com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:547)
failure:
for host xx.xx.x.xxx trying to GET /application/login.jsp, service-j2ee reports: com.mchange.v2.resourcepool.CannotAcquireResourceException: A ResourcePool could not acquire a resource from its primary factory or source. at
com.mchange.v2.resourcepool.BasicResourcePool.awaitAvailable(BasicResourcePool.java:1319) at
com.mchange.v2.resourcepool.BasicResourcePool.prelimCheckoutResource(BasicResourcePool.java:557) at
com.mchange.v2.resourcepool.BasicResourcePool.checkoutResource(BasicResourcePool.java:477) at
com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutPooledConnection(C3P0PooledConnectionPool.java:525) at
com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource.getConnection(AbstractPoolBackedDataSource.java:128) at
org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:113) at
org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:79) at
org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:379) at
org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:455) at
org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:463) at
org.springframework.jdbc.core.simple.SimpleJdbcTemplate.query(SimpleJdbcTemplate.java:187) at
gov.nyc.oer.dao.SiteConfigDao.getSiteConfig(Unknown Source) at
gov.nyc.oer.manager.SiteConfigManager.getSiteConfig(Unknown Source) at
gov.nyc.oer.manager.SiteConfigManager.afterPropertiesSet(Unknown Source) at
gov.nyc.oer.manager.SiteConfigManager.getValue(Unknown Source) at
org.apache.jsp.login_jsp._jspService(login_jsp.java:67) at
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:80) at
javax.servlet.http.HttpServlet.service(HttpServlet.java:917) at
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:373) at
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:457) at
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:351) at
javax.servlet.http.HttpServlet.service(HttpServlet.java:917) at
org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:398) at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304) at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:185) at
org.springframework.security.util.FilterChainProxy.doFilter(FilterChainProxy.java:169) at
org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:183) at
org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:138) at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:217) at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:185) at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) at
org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:255) at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:188) at
org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:586) at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:556) at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:187) at
org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:586) at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:556) at
com.sun.webserver.connector.nsapi.NSAPIProcessor.service(NSAPIProcessor.java:160)
Server Configuration:
Java: Enabled
Java Home: ${WS_JDK_HOME}
Ignore Environment Class Path: Enabled
Class Path Prefix: None
Server Class Path:
${WS_INSTALL_ROOT}/lib/webserv-rt.jar
${WS_INSTALL_ROOT}/lib/pwc.jar
${WS_INSTALL_ROOT}/lib/ant.jar
${java.home}/lib/tools.jar
${WS_INSTALL_ROOT}/lib/ktsearch.jar
${WS_INSTALL_ROOT}/lib/webserv-jstl.jar
${WS_INSTALL_ROOT}/lib/jsf-impl.jar
${WS_INSTALL_ROOT}/lib/jsf-api.jar
${WS_INSTALL_ROOT}/lib/webserv-jwsdp.jar
${WS_INSTALL_ROOT}/lib/container-auth.jar
${WS_INSTALL_ROOT}/lib/mail.jar
${WS_INSTALL_ROOT}/lib/activation.jar
Class Path Suffix: ${WS_INSTALL_ROOT}/lib/ojdbc14.jar
JVM Options:
-Djava.security.auth.login.config=login.conf
-Xms128m -Xmx256m
-Djdbc.drivers=oracle.jdbc.driver.OracleDriver
Looks like your database connection is not defined on your sun java web server 7. On this website you can find out how to define it.