Specifying a database in JDBC URL for Netezza - jdbc

When connecting to Netezza via JDBC, the database in the URL is a required field - e.g. the value sales in the example URL jdbc:netezza://main:5490/sales;user=admin;password=password
The first time I connect to a Netezza instance, I don't (necessarily) know the name of a database on the appliance. Guessing a database name is a very time consuming exercise.
In this scenario, what value should I provide? Is there a "use default" option, a way to list databases, or a specific database name that will always work (e.g. a system database)?

Netezza will always have one main database: system.
You cannot delete the system database.
I would suggest that you connect to jdbc:netezza://hostname:5480/system.
Once connected, you can list the databases that your user has access to, using
select database
from _v_database;

I can't answer definitively, but it appears that every Netezza appliance by default has a database named TESTDB. This is at least true for all the appliances to which I have access.
Users or administrators may be able to delete this database, but it's a good bet if you need a database to which to connect.

Related

Previous table appearing in new connection in Oracle database

Every time I create a new connection under the same common user on the SQL Developer tool it automatically copies the table(s) of the previous connection.
I am using Oracle Database 19c on the SQL developer tool.
In the below picture, there is a table having 2 columns.
In the below image, I have created a new connection, but it already has the previous tables.
troubleshooting steps I have followed so far -:
disconnected the previous connection: not solved
deleted the previous tables & connection: not solved
restarted SQL developer tool: not solved
deleted user and created again: this works but can't do it every time.
I have created a table using steps on this website: sqlserverguides
Please Advise :-)
The answer to your question here is that you are not doing what you think you are doing.
The objects newfirm and newtable are not tables, these are connections.
A connection needs a username and a password, a hostname to connect to, a port number, and a service name (or SID).
Once you are connected to a database server, all the "folders" you see under that connection are all related to the user used for the connection.
If you want to look at other users (be it sys or service users, or "people"), then you need to go to the folder "other users" in the same tree.
The screenshots you are showing there in your question only show 2 distinct connections (we don't know if the same details such as username + hostname were used) each with their own label/name (newfirm and newtable).
You can't "disconnect" a table, you also can't delete it .. you can drop it however which is likely what you meant.
In your screenshots, what you are pointing at and calling columns are actually tables.
Those things that you are pointing at and calling "previous table" and "new table" are not tables but connections (to a database server using a specific username).
You do not show any code you may be using, which would be useful.
If you want to drop a table (i.e. delete), you use the DROP command:
DROP TABLE user.tablename;
It is not possible for 2 tables with the same name to exist in the same schema (aka user).

Database Link - Test connection does not work

I have two databases that have tables with identical schema. I want to compare the two tables. I learned that cross DB queries need a Database Link.
I use SQL developer and here are the properties of the connection that works
Connection Name: MyConn
UserName:SomeUser
password:SomePassword
Connection Type: Basic
Role: default
Host Name: 12.12.12.12
port:2521
SID: xe
I tired this command to create Database link
CREATE DATABASE LINK MyDBLink
CONNECT TO SomeUser
IDENTIFIED BY "SomePassword"
USING '(DESCRIPTION=
(ADDRESS=(PROTOCOL=TCP)(HOST=12.12.12.12)(PORT=2521))
(CONNECT_DATA=(SID=xe)))';
The command creates a link but when I try to test the link, the connection does not work. The connection times out in 60s.
Am I missing something ?
The Database-Link is between the two databases and not "outgoing" from your local sqldeveloper/client.
So even if you can reach the remote database from your local client, the remote database-server where you created the link might (and in this case indeed does) not reach the target of the database link.
The database link itself is created no matter if the remote database is reachable, or the credentials are incorrect, etc.
If you have the possibility you should directly log on the database server of the database where you created the link and check the network connection to the database server you want to reach from there. Using telnet might help you.
The best solution is to look at the network or operating system and open a path between the two servers, and then the database link should work. If that's not possible, you can use your desktop PC as a proxy.
The official way to route around network issues is to use Oracle Connection Manager. But in my experience that program is a bit hard to configure.
Another option is to create a database on your desktop, and create two database links to each server. If this desktop database is only used for linking to others, then the free Express Edition should be good enough. If you go down this route, be careful of performance problems when involving 3 databases. You'll probably want to compare hashes instead of actual data, to avoid network problems.

Pl-Sql User Connection

I've been starting oracle on my job. But i've been using MS all the time. Now i have problem on User-Shema structure. I tryed a create table with sql query, but table had been created in somewhere else then i wanted. (I've already created a user named LPA) I just wrote the query, and table is in the (GeneralDatabase) Tablespaces->Users->(Here). I want to create a table in LPA schema, under the table folder. I've been searching for it but i could'nt get it. So need some help please.
PS:I found that i need to connect with user, than write to query with TS_LPA(Thats my tablespace). But i also cant connect with the user LPA.(We can say this is my first problem)
In Oracle there is no "dbo" or default schema, in case that is what you are looking for. You must specify the target user account when you connect (log in) to the database, and that account will be used as the default schema for all of your subsequent actions. (This is similar to a home directory in Linux, where if I log in as williamr and create a file, it will belong to williamr and not some generic default account.)
In your case I suspect you are connecting as SYS or similar, in which case your table now belongs to SYS (or whoever you are connected as). You'll need to drop it and try again.
If you don't want to post the connect string you used to connect initially for some reason, then execute the following query to see your current schema:
select user, sys_context('userenv','current_schema') from dual;
(Normally user and sys_context('userenv','current_schema') will be the same, but worth double-checking.)
In PL/SQL Developer you can only issue connect commands from a Command window (not a SQL window). Alternatively you can use the 'log on' menu tool, or Session > Set Main Connection from the menu, or (best if you want to reuse it later) Tools > Define Connections, which has a 'Test...' button to validate a new connection. You'll need the username, password and database service name (not just username and password).
connect with LPA user.
specify the schema name before table name.
create table LPA.tbl_name(col1 datatype1,....);

Confusion in Oracle naming

I wanted to form oracle database URL for my JDBC conection and few websites say SID should be part of URL and few say schema name.
Please compare schema, service name and SID in ORACLE? And how they are related?
is it like SID:schema is 1:n as in one SID can point to n schemas?
Please explain with the relation between them.
A SID is the unique identifier for a database, or if it's a RAC system for an instance of a database.
A Service is an identifier for a service offered by the database, and the database should be configured for services such as "BILLING_APP" or "CUST_WEBSITE". http://docs.oracle.com/cd/B28359_01/server.111/b28320/initparams217.htm
Don't confuse a database and an instance, by the way. A database is the set of data and control (etc) files, the instance is the memory areas and processes that access it. RAC has multiple instances per database, each of which can register with the listener to offer all or a subset of the total services offered by the database.
A schema is effectively the username that owns the objects, and there can be multiple schemas in the database.
So an application should be referencing a SERVICE to connect to, through a listener on a certain host and port. The listener resolves this to a database (possibly one of many that register to offer that service). The connection is made to the database as a user who might or might not be the owner of the schema. Typically the connection is not made as the schema owner for security reasons -- in fact the best level of security is to connect as User_A, calling code in User_B's schema, whicxh references tables in other users' schemas.
A SID is a Service ID and refers to a single Oracle database instance
A service name is very like a SID but multiple SIDs can be referenced by one Service Name
E.g. in a Dataguard scenario, the primary instance might be SID_01 and ORA_SRV. SID_02 and SID_03 are running somewhere on the network and receiving and applying the log files. SID_01 fails and SID_02 is brought up (Mounted and Opened) and now exposes itself ont he network as ORA_SRV.
Similarly with RAC multiple SIDs make up a single Service.
A schema is in effect a user.
A JDBC connection will be in some form of "HOST:PORT:(SID or Service name)". You will have to connect to the DB and will do so with a username and password. The username will (almost always) connect you to a schema of that name. You can can reference objects in another schema with dotted notation in your sql, e.g. SCHEMA.OBJECT_NAME

Change Oracle Schema at runtime when using SubSonic

In my project, I am using Oracle Database and SubSonic for DAL. I have a problem with SubSonic and Oracle Schema, that is:
When developing, I used a schema DEV in Oracle Database and generate DAL using SubSonic.
After that when release to customer, he used a new schema TEST in Oracle Database and changed the connection string in app.config to connect to Oracle. The error will appear, that is “Table or View does not exist”. I found this error and see that the schema of tables is still DEV.
I do not want re-generate DAL after change schema and when released to the customer. Please help me.
Firstly, your schema should not be DEV. DEV is a user or role.
Your schema name should be related to the data content (eg ACCOUNTS or SALES)
Secondly, consider whether you or the customer is going to decide the schema name. Say you have a product called FLINTSTONE. You may decide that the schema name should be FLINTSTONE. However your customer may want to run two instances of your product (eg one for local sales, the other for international) and use the same database. So they want FS_LOCAL and FS_INTER as the schema names. Is that option a feature of your product ?
Next, decide if your application should connect as the schema owner. There are good security reasons for NOT doing that. For example, the schema owner has privileges to drop tables, which is generally something the application doesn't do and thus, on the principle of least privilege, is something your application shouldn't have privileges to do.
Generally I would recommend some config parameter for the application for the schema name, and after connecting to the database, the app should do an "ALTER SESSION SET CURRENT_SCHEMA = 'whatever was it the config file'". The application database user would need the appropriate insert/update/delete/select/execute privileges on the objects in the application schema. If the application can't do that, you can have a LOGON trigger in the database.
Gary is correct in not using DEV as a schema on your own machine. In using Oracle we typically set up the schema as what the client is going to name their schema. This however does not fix your issue. What you need to do is create a global alias in Oracle that maps say DEV to CLIENTSCHEMA. You should still rename the schema on your machine but this will allow your schema to differ from your clients.

Resources