I'm trying to create a JDBC data source in Oracle WebLogic server and getting some error. I can log in the web console http://localhost:7001/console using user name + password and I followed the Youtube video / tutorial page - Configuring a JDBC data source as same.
I have a wireless connection and I get the Host name (# 12 in the tutorial ) by typing
ipconfig getifaddr en0
in the Mac OS terminal. It returns 10.131.173.138 ( the same format, I changed three random digits ) and I put it inside the Host name and also filled up all other information's. However, after that when I'm trying to test the set up by clicking Test Configuration, it returns me the following errors that I provided below -
Connection test failed.
Message icon - Error IO Error: The Network Adapter could not establish the connectionoracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:800)oracle.jdbc.driver.PhysicalConnection.connect(PhysicalConnection.java:793)oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:33)oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:614)weblogic.jdbc.common.internal.DataSourceUtil.testConnection0(DataSourceUtil.java:340)weblogic.jdbc.common.internal.DataSourceUtil.access$000(DataSourceUtil.java:22)weblogic.jdbc.common.internal.DataSourceUtil$1.run(DataSourceUtil.java:254)java.security.AccessController.doPrivileged(Native Method)weblogic.jdbc.common.internal.DataSourceUtil.testConnection(DataSourceUtil.java:251)com.bea.console.utils.jdbc.JDBCUtils.testConnection(JDBCUtils.java:751)com.bea.console.actions.jdbc.datasources.createjdbcdatasource.CreateJDBCDataSource.testConnectionConfiguration(CreateJDBCDataSource.java:479)sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)java.lang.reflect.Method.invoke(Method.java:606)org.apache.beehive.netui.pageflow.FlowController.invokeActionMethod(FlowController.java:870)org.apache.beehive.netui.pageflow.FlowController.getActionMethodForward(FlowController.java:809)org.apache.beehive.netui.pageflow.FlowController.internalExecute(FlowController.java:478)org.apache.beehive.netui.pageflow.PageFlowController.internalExecute(PageFlowController.java:306)org.apache.beehive.netui.pageflow.FlowController.execute(FlowController.java:336)...
I think it mainly says The Network Adapter could not establish the connection
However, I don't have much knowledge what to do to establish the connection properly. Thanks.
You need a real database with correct values in the jdbc URL:
i.e.
For example, if the database to which you want to connect resides on host prodHost, at port 1521, and system identifier (SID) ORCL, and you want to connect with user name scott and password tiger, then use either of the two following connection strings:
Using host:port:sid syntax:
String connString="jdbc:oracle:thin:#prodHost:1521:ORCL";
Related
Using SQL Server Management Studio, I can log on to a local server, the name is:
BOB14630\SQL2012
(named instance of SQL2012 as I have SQL Server 2008 R2 and SQL Server 2012 on the same machine).
It logs in fine.
I also have a webapp and am trying to connect to a database called 'Repserv' on that server and am using a properties file to store the config parameters:
If I say:
dbConnectString=jdbc:jtds:sqlserver://BOB14630/Repserv;instance=SQL2012
it gives:
java.sql.SQLException: Server BOB14630 has no instance named SQL2012
If I say:
dbConnectString=jdbc:jtds:sqlserver://BOB14630\\SQL2012/Repserv
it gives:
java.sql.SQLException: Unknown server host name 'BOB14630\SQL2012'
What is the correct way to specify these parameters to get the web app to connect?
Thanks.
The link in the comment by Berger above gave the solution (the tcp/ip protocol was disabled). After enabling it and changing the connection string to the following, it worked:
dbConnectString=jdbc:jtds:sqlserver://BOB14630/Repserv;instance=SQL2012
I am new to Oracle, and am trying to run a simple example code with Java, but am getting this error when executing the code.. I am able to start up the listener via CMD and am also able to run SQL Plus. Can anyone give me a hand and tell me what I might be doing wrong?
Update:
I am using JDBC.
Database is local, and I actually had it working but it stopped working just today. I'm not really sure why though. Would you mind giving me some procedures to follow by since I don't know much.
Either:
The database isn't running
You got the URL wrong
There is a firewall in the way.
(This strange error message is produced by Oracle's JDBC driver when it can't connect to the database server. 'Network adapter' appears to refer to some component of their code, which isn't very useful. Real network adapters (NICs) don't establish connections at all: TCP protocol stacks do that. It would have been a lot more useful if they had just let the original ConnectException be thrown, or at least used its error message and let it appear in the stack trace.)
I had the same problem, and this is how I fixed it.
I was using the wrong port for my connection.
private final String DB_URL = "jdbc:oracle:thin:#localhost:1521:orcll"; // 1521 my wrong port
go to your localhost
(my localhost address) : https://localhost:1158/em
login
user name
password
connect as --> normal
Below 'General' click on LISTENER_localhost
look at you port number
Net Address (ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1522))
Connect to port 1522
Edit you connection
change port 1521 to 1522.
done
Another thing you might want to check that the listener.ora file matches the way you are trying to connect to the DB. If you were connecting via a localhost reference and your listener.ora file got changed from:
HOST = localhost
to
HOST = 192.168.XX.XX
then this can cause the error that you had unless you update your hosts file to accommodate for this. Someone might have made this change to allow for remote connections to the DB from other machines.
I figured out that in my case, my database was in different subnet than the subnet from where i was trying to access the db.
I had this error when i renamed the pc in the windows-properties. The pc-name must be updated in the listener.ora-file
Most probably you have listener configured wrongly, the hostname you specify in connection string must be the same as in the listener.
First check the Firewall and network related issues.
Check if Oracle Listener service is available and running. If not you may use Oracle Net Configuration Assistant tool to add and register new listener.
If the above steps are ok then you need to configure Oracle Listener appropriately. You may use Oracle Net Manager tool or edit β%ORACLE_HOME%\network\admin\listener.oraβ file manually.
There are 2 options that need to be considered carefully:
Listening Locations associated with the Listener β Hostname(IP) and Port in Listening Location must exactly match the ones used in the connection string.
For example, if you use 192.168.74.139 as target hostname, then there must be Listening Location registered with the same IP address.
Also make sure the you use the same SID as indicated in Database Service associated with the Listener.
https://adhoctuts.com/fix-oracle-io-error-the-network-adapter-could-not-establish-the-connection-error/
IO Error: The Network Adapter could not establish the connection (CONNECTION_ID=iKQM6lBbSLiArrYuDqud8A==)
if you are facing this issue
1- make sure you have downloaded oracle databases like oracle 11g,19c, 21c, or any latest databases.
2- search for services in your computer or type win+r then services.mis then search for oracleservice you will find orcl or xe or any other sid like oracleserviceorcl;
after that you can test your connection using sql developer, sql plus or cmd
To resolve the Network Adapter Error I had to remove the - in the name of the computer name.
In my case, I needed to specify a viahost and viauser. Worth trying if you're in a complex system. :)
For me the basic oracle only was not installed. Please ensure you have oracle installed and then try checking host and port.
I was having issues with this as well. I was using the jdbc connection string to connect to the database. The hostname was incorrectly configured in the string. I am using Mac, and the same string was being used on Windows machines without an issue. On my connection string, I had to make sure that I had the full url with the appending "organizationname.com" to the end of the hostname.
Hope this helps.
Just try to re-create connection. In my situation one of jdbc connection stopped working for no reason. From console sqlplus was working ok.
It took me 2 hours to realize that If i create the same connection - it works.
I am trying to configure DataSources with WebLogic 10.3 and database is MySQL Server 5.5 , On entering the following
Driver Class Name ="com.mysql.jdbc.Driver"
url =jdbc:mysql://localhost:3306/weblogicdb
Database User Name =root (User name of Database MySql Server)
Password =123(Password name of Database MySql Server)
Confirm Password =123
and on clicking TestConfiguration, I get the following error.
Connection test failed.
Message icon - Error Unknown database 'weblogicdb'<br/>com.mysql.jdbc.SQLError.createSQLException(SQLError.java:930)
<br/>com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2864)
<br/>com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:806)
<br/>com.mysql.jdbc.MysqlIO.secureAuth411(MysqlIO.java:3263)
<br/>com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1176)
<br/>com.mysql.jdbc.Connection.createNewIO(Connection.java:2638)
<br/>com.mysql.jdbc.Connection.<init>(Connection.java:1525)
<br/>com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:260)
<br/>com.bea.console.utils.jdbc.JDBCUtils.testConnection(JDBCUtils.java:505)
<br/>com.bea.console.actions.jdbc.datasources.createjdbcdatasource.CreateJDBCDataSource.testConnectionConfiguration(CreateJDBCDataSource.java:369)
<br/>sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)<br/>sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
<br/>sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)<br/>java.lang.reflect.Method.invoke(Method.java:597)
<br/>org.apache.beehive.netui.pageflow.FlowController.invokeActionMethod(FlowController.java:870)
<br/>org.apache.beehive.netui.pageflow.FlowController.getActionMethodForward(FlowController.java:809)
<br/>org.apache.beehive.netui.pageflow.FlowController.internalExecute(FlowController.java:478)
<br/>org.apache.beehive.netui.pageflow.PageFlowController.internalExecute(PageFlowController.java:306)
<br/>org.apache.beehive.netui.pageflow.FlowController.execute(FlowController.java:336)
<br/>org.apache.beehive.netui.pageflow.internal.FlowControllerAction.execute(FlowControllerAction.java:52)<br/>...
I was looking into many blogs and previously asked questions, where they it could be because of username and password being incorrect. But that is not the issue in my case, I have rechecked it. on using the same username and password, I was able to log into my MySQL database.
Kindly help me in configuring the system.
Error stack clearly says that:
Message icon - Error Unknown database 'weblogicdb'
It seems you have input a wrong database name.
You might be succeeding with username/passwords to MySQL server.
But the server might have multiple databases in it and 'weblogicdb' is not the correct database name you are trying to connect to.
To see what databases the MySQL Server has in it, execute the following command either using java or any other MySQL clients like MySQL command line, SQLyog, PHPMyAdmin etc.
show databases();
This statement should result all the databases available.
Identify the appropriate one for your program and use the same in your code.
To connect through java to execute the above statement, db url should be:
url =jdbc:mysql://localhost:3306/?user=usernamevalue&password=passwordvalue
I trying to test the connection with my local sql DB. I have this code:
try{
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver").newInstance();
DriverManager.getConnection("jdbc:sqlserver://localhost:1433;databaseName=SocialFamilyTree;user=SOSCOMP");
}catch(Exception e){
System.out.println("Couldn't get database connection.");
e.printStackTrace();
}
I tried many users. my windows user is SOSCOMP and doesn't have a password. I also know that SQL 2008 create users as "sys" "dbo", I tried these too. I'm always getting:
Couldn't get database connection.
com.microsoft.sqlserver.jdbc.SQLServerException: Login failed for user 'SOSCOMP'.
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:196)
at com.microsoft.sqlserver.jdbc.TDSTokenHandler.onEOF(tdsparser.java:246)
at com.microsoft.sqlserver.jdbc.TDSParser.parse(tdsparser.java:83)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.sendLogon(SQLServerConnection.java:2532)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.logon(SQLServerConnection.java:1929)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.access$000(SQLServerConnection.java:41)
at com.microsoft.sqlserver.jdbc.SQLServerConnection$LogonCommand.doExecute(SQLServerConnection.java:1917)
at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:4026)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:1416)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:1061)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:833)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:716)
at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:841)
at java.sql.DriverManager.getConnection(DriverManager.java:579)
at java.sql.DriverManager.getConnection(DriverManager.java:243)
at FT_Receiver.FT_Receiver.main(FT_Receiver.java:12)
Any ideas?
Thanks
If you try to connect with database which is using windows authentication, you can use 'integratedSecurity' option in your connection string.
DriverManager.getConnection("jdbc:sqlserver://localhost:1433;databaseName=SocialFamilyTree;integratedSecurity=true;");
Having been through this very recently the steps I took to solve pretty much the same problem were
use SQL Server Management Studio to log in with the desired account and confirm access to read (and write if necessary)
Use SQL Server Configuration Manager to confirm that the server instance is listening on the IP address being targetted
Disable the firewall to check that isn't getting in the way (and add an exception if necessary for future use)
The absolute kicker for me was understanding what IP addresses and ports the instance was set to listen on so that when I constructed the connection string the connection wasn't being rejected.
Also, if you want to connect using Windows logins you need to ensure the SQL instance is configured for mixed mode authentication (i.e. to allow Windows and SQL logins)
Since you get this error,the Sql server correctly listens to the port.
Open Sql Server Management Studio connect to your Server.
right click on the server's icon and choose properties.
Go to the security tab and tick Sql Server and Windows
Authentication mode.
If you want to define a user,go from the tree, to Security->Logins,right click on logins folder and click "New Login".
Now your server should work with this Url String.
Use the log file of the Server that may help you understand its working.
Re: Did it. still WARNING: Failed to load the sqljdbc_auth.dll cause :- no sqljdbc_auth in java.library.path β Mike Oct 7 at 14:03
you have to add the path to sqljdbc_auth.dll by adding this under VM arguments in Eclipse or commandline if you're running from the shell:
-Djava.library.path="\MS SQL Server JDBC Driver 3.0\sqljdbc_3.0\enu\auth\x86"
that's if you're running 32 bit Windows. else the final subdir changes accordingly.
I think this might be a better answer though, to setting up SQL Server user based authentication:
Connecting SQL Server 2008 to Java: Login failed for user error
(I try to summarize it here: http://silveira.wikidot.com/sql-server)
I also faced the same issue, In my case the following things are configured wrongly
Two SQL (versions) servers are running in my system --> Sol: Please check ourselves which server we are pointing.
Ports are configured as dynamic --> Sol: we should set port 1433 and dynamic port should be 0, if we are connected to specific port.
While creating the new login (user) I have selected the option " change password after first login "--> Sol: we should not select this option while creating the new login, if we are trying connecting from some other service like Openfire.
I have a running local instance of PostgreSql on a linux machine. When I use psql command from the shell I success to log in without any problem. I need to connect to the PostgreSql via the JDBC, but I don't know what exactly should I pass as url parameter to DriverManager.getConnection().
It should start with jdbc:postgresql: but what's going next?
I was told by the system group that a database with was created like user name. e.g. if my user is jutky a db named jutky was created, but when I try to open a connection to jdbc:postgresql:jutky I get an error
org.postgresql.util.PSQLException: FATAL: password authentication failed for user "jutky"
:(
Additional info
When I login via the psql I'm not prompted for the password, so when I try to login via JDBC I pass an empty string as a password - is it correct, or should I pass null or something?
When I type psql --help in the shell I see among the rest this line:
Connection options:
-h, --host=HOSTNAME database server host or socket directory (default: "/var/run/postgresql")
So I understand that I connect to PostgreSql via a socket directory, does that matters something to the URL string in the JDBC?
EDIT
First thanks for the answers.
Second: its not first time I'm using JDBC and in particular not the first time I'm connecting to the PostgreSql from JDBC, so I know the general rules and I have read the documentations. However in the described case I'm not sure how exactly should I construct the connection string if the instance is running via the socket directory and what password should I provide. Because when I login via the psql I'm not prompted for password at all.
Thanks in advance.
In addition to other answers note that by default Postgres is configured to accept connections via Unix sockets with authentication based on your operating system account, that's why psql works fine and doesn't require the password.
JDBC connections are made over TCP/IP with password authentication, so you need to modify pg_hba.conf accordingly. For example, this line allows TCP/IP connections from the same machine to all databases for all users with password authentication:
host all all 127.0.0.1/32 md5
After adding this line jdbc:postgresql:databasename should work.
EDIT: You can't create a JDBC connection over Unix socket since PostgreSQL JDBC driver can only work over TCP/IP. The password you use when creating JDBC connection is the password assigned to your user. If you don't have it, you can assign it, for example, using ALTER USER command. See 19.3. Authentication methods.
See also:
19.1. The pg_hba.conf file
It's all explained in official documentation.
This is the relevant part:
String url = "jdbc:postgresql://localhost/test?user=fred&password=secret&ssl=true";
Connection conn = DriverManager.getConnection(url);