How to pre-create or allow autocreation of H2 database? - windows

I am trying to open test url
jdbc:h2:tcp://localhost/~/test
from H2 web interface, but it says
Database "D:/Users/USERNAME/test" not found, either pre-create it or
allow remote database creation (not recommended in secure
environments)
How to fulfil either pf propositions?

If you have a separate H2 Server process (launched from a jar file or as a service), you can open H2 Console from its icon in the system tray and use jdbc:h2:~/test URL in it, this copy of H2 Console should be able to create embedded databases automatically (unless remote access from other hosts was enabled). Other Java processes will still need jdbc:h2:tcp://localhost/~/test URL for connections to this database and they can use this remote URL after creation of embedded database on the server.
If H2 Console and TCP Server of H2 were launched from your application, your application should create this database by itself by establishing a connection with the same embedded URL jdbc:h2:~/test first.
You can also use a shell tool or any other way to create your database:
https://h2database.com/html/tutorial.html#creating_new_databases
All these ways also require the jdbc:h2:~/test URL to be used during creation.
There is also a flag to enable remote database creation, but this feature opens a security hole, either local (if remote connections are disabled by default) or remote if they were explicitly enabled. You should avoid usage of this feature.

Related

How can I allow an external application to connect directly to my Ruby on Rails-integrated PostgreSQL database?

I have one database, and several applications that need to use it (one Ruby on Rails app, with which the database is integrated by default, and a bunch of Minecraft servers running Java plugins). Right now, I am using my web application's REST api to access the database.
So: plugin -> api -> db -> api -> plugin
I am looking for a way for my plugins to access the database directly, without having to first go through the web application.
plugin -> db -> plugin
How can I allow an external application to access my database? How can I ensure that only certain applications are allowed to access the db? (Also: SHOULD I be doing this at all?)
Take a look into how ActiveRecord connects to the database, and you'll see that it simply uses the same way to connect to Postgres (a login connection string, or set of credentials, etc.), and that same method can be used by any other application.
Basically this means that if another application knows:
The URL or IP address where your DB is hosted
The username
The password
The port
... and there are no restrictions in place such as firewall rules that prevent access, then the application should be able to talk to the DB directly. ActiveRecord is basically just a software layer on top of the DB, but it doesn't "own" or "control" the database. Your Rails app is technically a client of the DB server.

how can know database name in oracle web logic server

I'm using oracle web logic server. How can I find out the database name and port number?
You can use nslookup or tnsping to know the host name and port of the database.
nslookup DATABASE_SID
tnsping DATABASE_SID
1) You can login to the console and navigate to Data Sources (for WLS10 and above) and click the available data source and click the tab Connection Pool. You would need to navigate to the tab Connection Pool if WLS 8 is being used.
2) Alternatively you can go to the weblogic domain of your instance and check in the config directory , $WLS_DOMAIN/config/jdbc and view the contents of the datasource's xml file.

Firebird equivalent to H2 mixed mode and serialized mode?

Does anyone know how to set Firebird into mixed mode like H2 can with the AUTO_SERVER=TRUE option?
The H2 automatic mixed mode is described here.
What about serialized mode?
Notice it should be possible because it is mentioned here
A Firebird server - by default - accepts multiple connections. You don't have to do configure anything to enable that. The only exception is if the administrator of the server restricted access for maintenance.
Firebird embedded itself cannot serve as a normal server (accepting connections from outside the client application that embeds it), but depending on the Firebird version and the OS it is possible that the database file can be shared with a 'normal' Firebird server on the same machine.
Your second link is about accessing a database on network drive, which is not possible (or at least prevented by default) because that can cause corruption by limitations of locking and forced write guarantees. Also understand that in a database server like Firebird all clients of a single database (should) access the same server, and the server accesses a database file local to the server machine.

How can I temporarily disable Oracle connection from local Windows 7 machine to a db server?

For testing purposes. One option is to disable network connection but this seems to disable IIS for some reason.
I would like to prevent a web service to have a connection to a db on different machine. Changing anything on server side is not an option.
EDIT: I have to do this on specific point during the Web Service's (and it's consumer's) execution. I'm trying to simulate a situation where the connection to db is suddenly lost while serving a request.
If you are using TNS based naming for the database, remove the name temporarily from the tnanames.ora file.
To do it at the OS level, configure your Windows 7 Firewall (advanced seting). Add an outbound block rule for the IP/port of the DB server.

WebSphere to Oracle - doesn't accept correct password

In WebSphere 6.1 I have created a datasource to an Oracle 11g instance using the thin JDBC client.
In Oracle I have two users, one existing and another newly created.
My websphere datasource is OK if I use the component-managed authentication alias of the existing user, but fails with "invalid user/password" message if I use the alias of the new user. The error message is:
The test connection operation failed for data source MyDB (Non-XA) on
server nodeagent at node MY_node with the following exception:
java.sql.SQLException: ORA-01017: invalid username/password;
logon denied DSRA0010E: SQL State = 72000, Error Code = 1,017.
View JVM logs for further details.
There is nothing in the JVM logs. I have grepped all websphere logs and they do not mention my connection at all.
I can confirm that the username and password are correct by logging in via SQLPlus or (to prove the JDBC connection is OK) via SQuirreL.
I have checked in Oracle that the new user has all the system privs that the existing user has.
Any thoughts on what is going on or how I can debug this further?
Just FYI. I am guessing you are running WebSphere in Network Deployment mode.
This behavior you're experiencing is actually by design.
The reason for it is that the "Test Connection" button you see on the admin console, invokes the JDBC connection test from within the process of the Node Agent. There is no way for the J2C Alias information to propagate to the Node Agent without restarting it; some configuration objects take effect in WebSphere as soon as you save the configuration to the master repository, and some only take effect on a restart. J2C aliases take effect on restarts.
In a Network Deployment topology, you may have any number of server instances controlled by the same Node Agent. You may restart your server instances as you'd like, but unless you restart the Node Agent itself, the "test connection" button will never work.
It's a known WebSphere limitation... Which also exists on version 7.0, so don't be surprised when you test it during your next migration. :-)
If this happens to anyone else, I restarted WebSphere and all my problems went away. It's a true hallmark of quality software.
Oftentimes when people tell me they can't log into Oracle 11g with the correct password, I know they've been caught out by passwords becoming case-sensitive between 10g and 11g.
Try this :
data source definition
security
use the j2c alias both autentication managed by component and autentication managed by container
IBM WAS 8.5.5 Knowledge Center - Managing Java 2 Connector Architecture authentication data entries for JAAS
If you create or update a data source that points to a newly created J2C authentication data alias, the test connection fails to connect until you restart the deployment manager.
After you restart the deployment manager, the J2C authentication data is reflected in the runtime configuration. Any changes to the J2C authentication data fields require a deployment manager restart for the changes to take effect.
The node agent must also be restarted.
I have point my data source to componenet-manage authentication as well as container-managed authentication.Its working fine now........

Resources