Connecting to Remote DB2 Database (JSP) - database

Let me preface this by saying I am completely new at this kind of thing. Anyways..
I am trying to connect to a DB2 Database.
The server is running Ubuntu 12.04 and Apache Tomcat 7. The driver db2jcc.jar is included in the build path.
Here is my JSP code:
<%# page import="java.sql.*" %>
<% Class.forName("com.ibm.db2.jcc.DB2Driver");%>
<HTML>
<HEAD>
<TITLE>db2 connection</TITLE>
</HEAD>
<BODY>
<%
String url =
"jdbc:db2://IP_ADDR:60000/INST1" +
":user=USERNAME;password=PASSWORD;" +
"traceLevel=" +
(com.ibm.db2.jcc.DB2BaseDataSource.TRACE_ALL) + ";";
Connection con = java.sql.DriverManager.getConnection(url);
%>
</BODY>
</HTML>
The error message I am getting:
The application server rejected establishment of the connection.
An attempt was made to access a database, INST1, which was either not found or does not support transactions. ERRORCODE=-4499, SQLSTATE=08004
I checked out the IBM Support page on the issue here:
http://www-01.ibm.com/support/docview.wss?uid=swg21443723
It mentions using the target directory name, found by issuing the db2 list dcs directory command.
On the server, mine was initially blank, but I created an entry using the db2 catalog dcs database DB2INST1 as INST1 command.
Now my output for using db2 list dcs directory` is as follows:
Database Connection Services (DCS) Directory
Number of entries in the directory = 1
DCS 1 entry:
Local database name = DB2INST1
Target database name = INST1
Application requestor name =
DCS parameters =
Comment =
DCS directory release level = 0x0100
I reset the database by doing db2stop and db2start
Finally, I ran netstat -tulpn and saw the database was listening on port 60000. Output below:
tcp 0 0 0.0.0.0:60000 0.0.0.0:* LISTEN
2949/db2sysc
This is as far as I got. From what I can tell I am using the target database name and trying to connect to the correct port number.
Am I barking up the right tree here? Any help is greatly appreciated.
** Edit: Formatted answer to mustaccio's response **
On the server, I go down a level after I ssh on. I get 4 directories named <USERNAME>, dasusr1, db2fenc1, db2inst1
From there I did sudo su db2inst1 then ran the db2 list dcs directory command to get:
Database Connection Services (DCS) Directory
Number of entries in the directory = 1
DCS 1 entry:
Local database name = DB2INST1
Target database name = INST1
Application requestor name =
DCS parameters =
Comment =
DCS directory release level = 0x0100

It's been a while but for other people looking for a solution to this db2 connectivity problem. If people want to test physical connectivity of their development machine to the db2 server use CLPPlus that comes with the DB2 driver and manually put in the connection parameters to make sure you have physical connectivity. My environment is quite different than Garret's above but I want to offer one more clue that might help people connect. I was using VS 2015 enterprise with SSIS. I used CLPPlus to confirm physical connectivity then started trying to connect and ADO.Net source to db2. I had to override the port for my server credential db2server.mydomain.com:523 to override the port to 523. Then something funny happened. SSIS was fussing about the connection and I started looking at the parameters. One of the parameters was Authentication, which you could probably code in jdbc. I put in DB2 (as opposed to ldap or some other wallet) as the value for Authentication and it worked.

Related

Error configuring backup of team foundation server to samba shared path on debian 10 server

I have a samba 4 configured in debian 10(without joining domain) with my smb.conf configuration file:
[global]
bind interfaces only = yes
interfaces = 10.0.2.0/24
workgroup = SAMBA
idmap config * : backend = tdb
cups options = raw
encrypt passwords = yes
logging = file
smb encrypt = required
keep alive = 50
log file = /root/samba/%m.log
max log size = 100000
security = user
map to guest = Bad User
[server]
path = /server
writeable = yes
read only = no
browsable = yes
directory mask = 0770
create mask = 0770
valid users = juan
In tfs (windows server 2012) I configure the backup with the proposed path until I get the following error:
error:TF401002: The SQL Server Database Engine was unable to save the database backup in path \\ .... Give the SQL service account read and write access to that folder
I go to the database server and the account that does not have permissions to access is the following:
NT Service\SQLAgent$SQLTEAM2013
as ago to give permissions to that account for the samba shared folder ????
error:TF401002: The SQL Server Database Engine was unable to save the database backup in path \ .... Give the SQL service account read and write access to that folder
It seems that the sql account doesn't have sufficient permission.
As far as I know , the NT Service\SQLAgent$xxx account is a virtual account. This account has low user rights.
Generally, this account has no read and write permission for the shared path folder.
You could try to grant permission to this account and check if it could solve this issue.
In addition, you also need to make sure the target path is valid. For example: \\TFS2018\backup.
This ticket may be helpful.
Hope this helps.

Connecting to sql database

(I am a sql noob and I just can not figure this out on my own)
For some time now I have been trying to establish a connection to a SQL database in codename one but to no avail. First I tried connecting to a MariaDB database from one.com. All that's needed for the connection is
Database db = Display.getInstance().openOrCreate("databaseName");
if I am not mistaken, but I am guessing this implies that I have somehow already established a connection to the database. This is not the case however so it creates a new .sql file, right? I can recall that you can connect to a database in the services tab in Netbeans. I chose the MySQL(Connector/ J Driver) which should work with MariaDB, or should it? I entered all my data and i says that it can not establish connection to the database.
the error i get
So I thought I might as well try using localhost. I used XAMPP to host a database and connected in the netbeans services tab.
connected?
Now testing was needed to see if this works. I started the SQL journey with this https://www.codenameone.com/manual/files-storage-networking.html#_sql and integrated the part after "You can probably integrate this code into your app as a debugging tool". I changed database name to "mybase" (it's existance can be confirmed in picture 2). Ran the app, opened the dialog, entered "select ID from customers" and got: java.sql.SQLException: [SQLITE_ERROR] SQL error or missing database (no such table: customers) It does not get past the first call to "executeQuery". The customers table definitely exists so what am I missing to establish connection?
I really need instructions to connect to the localhost database and ideally also to the one hosted by my webhost provider.
Thanks,
Jona
The Database class is to access the SQLite DB on the mobile device. To connect to external databases, you'd have to do something different, such as a ConnectionRequest or Socket I think.

Permissions issue in SQL Server 2016 and R

We’re very experienced with SQL Server as well as R (as a standalone product). We’ve setup SQL Server 2016 test server (production version from MSDN) with R also installed. The machine works fine, and we’ve tried some rudimentary R, and that works fine as well (which also means that we’ve referred to this article from Microsoft: https://msdn.microsoft.com/en-us/library/mt696069.aspx).
So, the issue we’re having is trying to load an R script from a location on our network. For example:
source(“\\\\MyServer\\MyRDirectory\\MyRScript.R”);
Just in case UNC didn’t work, we tried mapping a network drive to a drive letter, but received the same, “No such file or directory” error message.
There seems to be a permissions issue accessing this file. If we copy that file to the local test server, it works fine. For example, we have no issue with this:
source(“C:\\Temp\\MyRScript.R”);
For this test, I am using SSMS 2016 and I am logged in as a Windows AD user with DBO permissions, and I have permissions to the remote folder. The SQL Server 2016 service accounts are also AD “users” with appropriate permissions. I read that R has its own user group (SQLRUserGroup) and 20 user accounts are in that group – all of this is assigned by SQL Server during the install; these are accounts that are local to the test machine. I suspect this is the issue: R/SQL Server must be trying to access that network folder/file as a local user – not an AD user with appropriate permissions.
Has anyone run into this and found a resolution that you can share?
FYI, as expected, running the following R script in SQL Server 2016 (SSMS):
execute sp_execute_external_script
#language = N’R’
, #script = N’ OutputDataSet<- data.frame(c(USERNAME=Sys.getenv("USERNAME")),HOME=Sys.getenv("HOME"))'
, #input_data_1 = N''
WITH RESULT SETS ((USERNAME varchar(200),HOME varchar(200)))
Reports that my script is running as "MSSQLSERVER01" with a local/home directory and GUID for that user. I'm sure that's the issue, but how do I change that to run as an AD user with proper permissions?
I get the strong feeling that this is not going to be possible, but can anyone here verify?
SQL Server R Services always runs the scripts in the context of worker accounts that are local to the system, for security and isolation purposes. And it is not possible to run them in the AD user context.

createuser could not connect to database postgres

Please don't move this question to askubuntu as I think this question is not OS-specific.
When I invoke the createuser postgres command (for now it doesn't matter if I provide any parameters or not), I'm getting this error:
createuser: could not connect to database postgres: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
Normally it means that the postgres server is down but not this time:
pg_lsclusters
Ver Cluster Port Status Owner Data directory Log file
9.4 main 5432 online postgres /var/lib/postgresql/9.4/main /var/log/postgresql/postgresql-9.4-main.log
sudo service postgresql status
9.4/main (port 5432): online
But it's true that there is no /tmp/.s.PGSQL.5432 file because my configuration file (/etc/postgresql/9.4/main/postgresql.conf) has this line:
unix_socket_directories = '/var/run/postgresql'
So I don't really understand why createuser whants to access /tmp/.s.PGSQL.5432? Can this path can be hardcoded into the createuser binary? I don't see any command line argument to specify the settings file location for createuser...
Have you started the service?
service postgresql start
The postgresql.conf file is read by the database server, but not by client applications (such as createuser, psql, ...). (In fact, the server configuration file cannot be read by client applications because the client would have to connect to the server, which could be halfway across the world, before it could possibly know where that configuration file lives).
Instead, you have to tell your client application where to find the socket directory.
If your client application (createuser) is connecting to the local host (which is must be because you are not specifying a different host), you use the host parameter to specify the name of the socket directory.
For example:
createuser -h /var/run/postgresql newusername
See http://www.postgresql.org/docs/devel/static/libpq-connect.html#LIBPQ-CONNECT-HOST
Hope that helps.

How to access Oracle database over network?

I am trying to accessing my Oracle database over Network. I have Google a lot and found many solutions, but those doesn't work for me.
The problem is that, I want to access my Oracle Database from One Computer to another Computer over my Local Network.
What I did is....
I found a Solution to modify listener.ora file with
(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=dbp.devProject.com)(PORT=1521)))
When I modify this file and tried to run and access the Database nothing will happens, and it throws an Error, the port number you have specified is used by another listener, so i have changed port Number but I am not able to access Database.
2. I have configure a new listener with the help of oracle's tool Net Manager, which made a Listener for me, but it does not make accessible database over Network.
Here Some required results.
lsnrctl status : Listener using listener name LISTENER has already been started.
Connection String : jdbc:oracle:thin:#dbp.devProject.com:4541:myDB
Database Version :
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
PL/SQL Release 11.2.0.1.0 - Production
CORE 11.2.0.1.0 Production
TNS for 64-bit Windows: Version 11.2.0.1.0 - Production
NLSRTL Version 11.2.0.1.0 - Production
status shows me this.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
STATUS of the LISTENER
Alias : LISTENER
Version : TNSLSNR for 64-bit Windows: Version 11.2.0.1.0 - Production
Start Date : 14-MAY-2015 11:58:05
Uptime : 0 days 2 hr. 29 min. 50 sec
Trace Level : off
Security : ON: Local OS Authentication
SNMP : OFF
Listener Parameter File : product\11.2.0\dbhome_1\network\admin\listener.ora
Listener Log File : \listener\alert\log.xml
Listening Endpoints Summary...
1. (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(PIPENAME=\\.\pipe\EXTPROC1521ipc)))
2. (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=127.0.0.1)(PORT=1521)))
Someone please Help me.
Thanks for your Help..
Whenever you encounter this kind of errors while creating remote access for you database, follow these steps beforehand.
Create a Listener using Net Manager tool of Oracle or create it Manually.
After generating Listener, check out "listener.ora"
[Located : ORACLE_INSTALLED_DIR\product\11.2.0\dbhome_1\NETWORK\ADMIN]
file, for your entry. (is there any Entry for the Listener which you have created just before. If you found your Entry than and than do next steps otherwise do it from FIRST step.)
If you found the Entry for your Listener, Open Command Prompt and fire command lsnrctl status. This will give you all currently running Listeners List, find out the one which you created just before.
Check out the Host Name and Port Number for your Listener.
Generate the Connection String as per the details you found in lsnrctl status
Connect with Database, and You can access the Database from anywhere in your Network.
If your host name and port number is listener then You could try this option by enabling port number in firewall settings.
Opening Ports in Windows Firewall
Open the Control Panel. ...
Open Windows Firewall. ...
Click the Advanced Settings link. ...
Select "Inbound Rules". ...
Create "New Rule" under "Inbound Rules". ...
Select "Port" from the first screen of the wizard. ...
Choose TCP or UDP. ...
Enter in the port range. ...
Finish the wizard.
Create an entry in TNSNAMES.ORA file on the system from which you are trying to connect to the database. (TNSNAMES.ORA is located in ORACLE_INSTALLATION_PATH/Network/Admin/ folder)
Sample entry:
DB_HOST_NAME =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = DB_HOST_NAME)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = XE)
)
)
If you have more than one Oracle clients installed, you might need to update this in all those TNSNAMES.ORA

Resources