Determine if database exists?
Is is possible, through Java, to determine if a database exists on a particular database server? We have an application that will either create or migrate a database, and I need to add a check in the installer to ensure that the given database name exists before continuing. I'm looking for something that works with both SQL Server and Oracle (but SQL would be fine atm). Any help is greatly appreciated and thanks in advance.
As far as I know, you have to connect to the database and you are quite correct, it will only verify if you have rights to read from that database. If are wondering what to do if you don't have appropriate system rights in the database or ability to connect to the database, then you will have to go the registry route for Oracle and see if the database you are looking for has been registered--I will assume SQL does something similar, but I do not know. This assumes you will have rights enough on the server to search the registry.
Aside from the previous suggestions, you can literally search the server directory structures looking for the database you seek. This way you also have to have appropriate rights into the server.
Any way you look at it, you are going to have to have a login account and appropriate rights to find what you are looking for--however you choose to do the searching.
Similar Messages
-
How to determine logical database in a program?
Hello guys!
How to determine logical database in a program on Eclipse?
I have not found any options:
Thanks!Welcome to SDN
Check the table RSOSFIELDMAP
Assign points if useful
Regards
N Ganesh -
How to determine the database size corresponding to the nber records in DSO
Hi Colleagues,
I would like to determine the database size corresponding to my new BI project.
I know the number of records uploaded in the DSO from the source system for the intialization phase.
How can I deduct the database size / disk size corresponding to the number of record uploaded ?
Thanks,Hi Ram,
I am with SAP BI Release SAPKW70019
I do not have the option Single Table analysis -
I have in DB02 or ST04 the following options.
*- Space*
-- space overview
->database
--overview
->users
--overview
--detailed analysis
-> tablespaces
--overview
--detailed analysis
-> segments
--overview
--Detailed analysis
--Detailed Analysis Aggregated
-> Additional Functions
--Collector Logs
--BW Analysis
Where should I go through ?
Thanks -
How to determine the database driver a report uses?
Hello experts. I'm using Crystal Report XI R2 and C# (.net 4.0 runtime).
For a given report, I'd like programmatically determine what database driver(s) a report and it's sub-reports use. The nice thing is that I don't want to change it.
When I refer to database drivers I'm talking about the choices one gets when starting a new report in the Crystal UI. Something like the following:
Access/Excel (DAO)
ADO.NET (XML)
Database Files
ODBC (RDO)
OLE DB (ADO)
I've looked into the developers help file that came with Crystal XI R2, crsdk_net_doc.chm, and can't find any references that would help. Maybe it's what I'm searching on.
My goal is for a given directory produce a list of rpt files that use OLE DB and a MS-SQL Server provider.
Thanks for looking at my question, any assistance is appreciated.
MikeAlso note since you are using 4.0 framework you must also be using VS 2010.
CR for VS 2010 is the only version supported with 4.0 framework.
See this page to download it: http://www.sdn.sap.com/irj/boc/crystalreports-dotnet
Or go back to VS 2008.
Code would look something like this:
public class frmMain : System.Windows.Forms.Form
CrystalDecisions.CrystalReports.Engine.ReportDocument rpt = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
CrystalDecisions.ReportAppServer.ClientDoc.ISCDReportClientDocument rptClientDoc;
New subrepoutine...
ISCDReportClientDocument rcd;
rcd = rptClientDoc;
CrystalDecisions.ReportAppServer.DataDefModel.ConnectionInfo oldConninfo;
CrystalDecisions.ReportAppServer.DataDefModel.ConnectionInfo newConnInfo = new CrystalDecisions.ReportAppServer.DataDefModel.ConnectionInfo();
CrystalDecisions.ReportAppServer.DataDefModel.Table oldTbl;
CrystalDecisions.ReportAppServer.DataDefModel.CommandTable newTbl = new CommandTable();
oldTbl = (CrystalDecisions.ReportAppServer.DataDefModel.Table)rcd.Database.Tables[0];
oldConninfo = oldTbl.ConnectionInfo.Clone(true);
Thank you
Don -
How to verify if a MySQL database exists?
Hi,
I have a JAVA application that read and writes in a MySQL database. At startup i wish to verify if a database exist... i know the command mysql_list_dbs() in MySQL is supposed to list availiable databases in a recordset but i cant made it work!?
someone knows how to do this?
thanks!This is a very interesting case ..... i dont' know if you are searching databases for establish conectivity, or simply your app is big, but a easy solution is check if the data base returns some resultset, one answer can be next ...
public boolean exist (String db){
Connection conexion;
Statement statement;
ResultSet resultset,result_filas;
Class.forName("com.mysql.jdbc.Driver").newInstance();
conexion = DriverManager.getConnection("jdbc:mysql://localhost/"+db);
statement = conexion.createStatement();
result_filas = statement.executeQuery("SELECT COUNT(*) FROM table");
while (result_filas.next()) {
numero_filas = result_filas.getInt(1);
if(numero_filas==0){
exist = false;
else{
if(numero_filas!=0){
exist = true;
return exist; -
How do you find if a LOGICAL DATABASE exists for your program requirements?
how do you find if a LOGICAL DATABASE exists for your program requirements?
please explain.Hi Ramana
One may not accurately pin point the LDB for ones requirement. But there some ways.
1. You can find with respect to the application you are working on. You can refer to the Table field TRDIR-APPL. The following are the values it has. So suppose if you have requirement for HR you can search for application 'P' :
A Assets accounting
D DASS control station
E RIVA
F Financial accounting
G General Ledger
H Human resources planning
I Maintenance
J RK projects
K Cost accounting
L Warehouse management
M Materials management
N Hospital
P Human resources
Q QSS
S System
V Sales
Y Customer head office
Z Customer branch
2. You can see the package in which your current is stored in SE80. Under the same package you can see if there are any LDBs. -
How to find if a logical database exists for your program requrements?
hi
How do you find if a logical database exists for your program requrements?
RegardsYou probably know the DB table that you'd like to query
try where used list : 'Logical database'
then you can see what interests you... -
Database.exists fails with "illegal flag specified to DB- exists" in 4.7.25
Hello all!
We are using the Java interface to the C based Oracle Berkeley DB version 4.7.25 under Solaris, Linux, and Winwoes XP, all using a 32-bit address space.
Our code is calling Database.get just to check to see if a key exists in the database.
That is working.
When I change our code to call Database.exists (as recommended in the FAQ) I get the error "illegal flag specified to DB->exists":
<blockquote><pre>
java.lang.IllegalArgumentException: Invalid argument: illegal flag specified to DB->exists
at com.sleepycat.db.internal.db_javaJNI.Db_exists(Native Method)
at com.sleepycat.db.internal.Db.exists(Db.java:323)
at com.sleepycat.db.Database.exists(Database.java:584)
</pre></blockquote>
In the call to Database.exists I am passing null for the txn parameter, just like the call to Database.get did.
If I construct a Transaction object and pass that in the call to Database.exists, exists works correctly.
Looking at the Berkeley DB source code for Database.exists shows the Java wrapper adds a flag if the txn parameter is null:
<blockquote><pre>
return OperationStatus.fromInt(
db.exists((txn == null) ? null : txn.txn, key,
((txn == null) ? autoCommitFlag : 0)));
</pre></blockquote>
The autoCommitFlag is initialized to DbConstants.DB_AUTO_COMMIT by the Database class if transactions are enabled for the database, which they are in our case.
The method __db_exists in the Berkeley DB C code does not accept the DB_AUTO_COMMIT:
<blockquote><pre>
if ((ret = __db_fchk(dbp->env, "DB-\>exists", flags,
DB_READ_COMMITTED | DB_READ_UNCOMMITTED | DB_RMW)) != 0)
return (ret);
</pre></blockquote>
In the Berkeley DB Reference Guide found here:
[http://www.oracle.com/technology/documentation/berkeley-db/db/ref/upgrade.4.4/autocommit.html]
There is this statement concerning the DB_AUTO_COMMIT flag and changes in 4.4:
<blockquote>
In previous Berkeley DB releases, the DB_AUTO_COMMIT flag was used in the C and C++ Berkeley DB APIs to wrap operations within a transaction without explicitly creating a transaction and passing the DB_TXN handle as part of the operation method call. In the 4.4 release, the DB_AUTO_COMMIT flag no longer needs to be explicitly specified.
</blockquote>
It also says:
<blockquote>
No related application changes are required for this release, as the DB_AUTO_COMMIT flag is ignored where it is no longer needed. However, application writers are encouraged to remove uses of the DB_AUTO_COMMIT flag in places where it is no longer needed.
</blockquote>
Maybe the situation has changed since 4.4, but that text from the reference manual seems to indicate that the Berkeley DB Database.exists Java code should not be passing the DB_AUTO_COMMIT flag and the Berkeley DB C method __db_exists must ignore DB_AUTO_COMMIT if it is passed.
Does this represent a defect in Oracle Berkeley DB, or has the situation changed in 4.7?
Thanks for any help!
GregHi Greg, thanks for the thorough diagnosis! You've definitely found a bug in BDB, we are currently validating a patch and hope to have it available for you soon.
Ben Schmeckpeper -
How to Determine Whether Columns Exist in a Table
Greetings,
Because of customizations to our product, certain database table structures vary between different client installations. Hence, in the code, I need to determine whether two columns exist in a certain table, in order to apply some business logic.
Please suggest a way for me to determine whether two named columns appear in a specific table. In other words, for example, I need to discover whether both columns SAL_GRADE and BONUS appear in the EMP table, or not. Only if both columns are defined, can I apply my business logic.
Thanks,
Avi.Avi,
Like this ?
SQL> declare
2 l_count number;
3 begin
4 select count(*)
5 into l_count
6 from user_tab_columns
7 where table_name = 'EMP'
8 and column_name in ('SALGRADE','BONUS')
9 ;
10 if l_count = 2
11 then
12 dbms_output.put_line('Both columns exist, so apply business logic');
13 else
14 dbms_output.put_line('One or both columns are missing, so don''t apply business logic');
15 end if;
16 end;
17 /
One or both columns are missing, so don't apply business logic
PL/SQL-procedure is geslaagd.Regards,
Rob. -
How to determine the database mirroring role via Powershell?
Is there a way to determine the current mirroring role of a database via Powershell without the use of t-sql?
With the Microsoft.SqlServer.Management.Smo namespace and database class I can determine the status, witness and partner of the mirrored database, but I can't determine the mirroring role of the current database. I basically want to get the same result
as the following t-sql query in powershell without using t-sql:
SELECT m.mirroring_role_desc
FROM sys.database_mirroring m JOIN sys.databases d
ON m.database_id = d.database_id
WHERE d.name = 'databasename'
I find it very strange that there is no class property to check for this, while it is an important property of the database. Of course I can use the output of this query in my powershell script for further processing, but I still hope that there is a property
where I can get this information.
TheSultan8Just to let you know, I've already found it. Here is a part of the code that I use for checking each mirrored database what mirroring role it has:
$sqlconnection="MYLAPTOP\SQL2008R2"
$smo = New-Object ('Microsoft.SqlServer.Management.Smo.Server') $sqlconnection
$mirroreddbs=$smo.Databases | where {$_.IsMirroringEnabled -eq "True"}
$sqlversionmajor=$smo.VersionMajor
foreach ($database in $mirroreddbs)
# Versions lower than SQL 2008 can't query a database in recovery mode
if ($sqlversionmajor -ge 10)
$dbrolevalue=$database.DatabaseOptions.Properties | where {$_.Name -eq "MirroringRole"}
$dbrole=$dbrolevalue.Value
One catch though, this only works on SQL 2008 and higher version.
TheSultan8 -
Posting Keys for Account Determination do not exist
This doubt in STO scenario:
STO - between 2 plants - different company codes under same client
Created STO from Receiving Plant in ME21N with document type NB
Based on that STO, Created Delivery in VL10B from supplying Plant
Tried PGI in VL02N from supplying Plant.
Received the Error Message as below:
Posting keys for account determination for transaction BUV do not exist
Message no. F5598
Diagnosis
The posting keys necessary for account determination for transaction BUV have not been set.
System Response
Because the posting key is missing, the system cannot generate any automatic postings.
Procedure
Maintain the posting keys necessary for transaction BUV.
kindly give the solution and advance thanks.
VaideeHi Vadee,
Account Determination for BUV has not been setup for PGI.
So , go to transaction OBYC and assign the account by double clicking BUV and give u r chart of accounts and check whether the account has been maintained. If not maintain.
If account has been maintained , select your account/valuation class and select posting keys push button and maintain the posting keys.
Regards,
Nani -
I am trying to programatically Enable and Disable database logging. Database is set to disable from Configure>Result Processing..., I write to Parameters.ModelPluginConfiguration.Plugins[1].PluginSpecific.Options.DisableDatabaseLogging value of False. This does not enables database and nothing gets comitted. All this customization is done in PreUUT.
Also need to have a precondition to find if a Parameter exists.
PropertyExists("Parameters.ModelPluginConfiguration.Plugins[Locals.DatabaseIndex].PluginSpecific.Options.DisableDatabaseLogging")
But the above always returns False. Need to receive True when Locals.DatabaseIndex is set to 1 as that is the location of Database under Configure>>ResultProcessing.
Thanks.
CLD,CTDYour lookup string is wrong. It has to look like this:
PropertyExists("Parameters.ModelPluginConfiguration.Plugins["+Str(Locals.DatabaseIndex)+"].PluginSpecific.Options.DisableDatabaseLogging")
hope this helps,
Norbert
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it. -
Determine if service exists?
In Powershell, how do you determine if a windows service exists and stop it?
thanksHi Scott_m,
Mike's script should work, to start powershell Conditional Operators, please also check these articles:
Introduction to PowerShell Conditional Operators
Introduction to The Windows PowerShell If Statement
If you have any feedback on our support, please
click here.
Best Regards,
Anna
TechNet Community Support -
How determine repository for existing IDM instance
Hello all! Here is an interesting one. I've inherited an IDM instance and have to find out about its repository (nobody seems to know as the consultants who set it up are long gone). I looked through the idm.war file but don't see anything regarding where its database instance is (I'm sure its not in LDAP or a flat file). Where is this data persisted and how can it be changed if need be? :-)
Thanks!Sorry - didn't see the last part of this.
If you want to change the assigned REPO, you can either use the correct flags / options with the "lh setRepo" command or you can run "lh setup" instead. The "lh setup" will launch a wizard-based window to take you through the steps to connect. This is where you can specify (drop-list, text entry) the type of REPO (files, DB) and how-to connect to it. Just be careful that when the REPO was originally created using the provided scripts, it would likely have been modified so that there's a specific account (ID, Password) that would be enabled for access. So net -- if you don't know the account credentials for remotely connecting to the existing or alternate REPO, I wouldn't go changing which REPO the instance points to.
Make sense? -
Determining my database files names and when created
Hi SOS,
I wanna ba able to determine the above, can you be of help.
Secondly, how can i also determined on command line who are still connected on a database?
thanks in advance
cube60select * from dba_data_files
select * from v$datafile
select * from v$session
Vadim Bobrov
Oracle Database Tools
http://www.fourthelephant.com
Maybe you are looking for
-
I have a problem with itunes when I sync the saved music and want to sync my iphone 5 ios 7.0.6 no longer passes the music thing is that just stays on "waiting for sync" and not worry please help are more than 400 songs that do not want to hear who a
-
Hi all, In LSMW, for the 5th step, ie Maintain field mapping, I am not getting any fields. Normally we get the set of fields and then we do the mapping. Please let me know what wrong i am doing. Thanks, Salil
-
Incomplete recovery after open resetlogs
hi gurus Every sunday,consistent backups are performed on your database.Because of a user error,you performed an incomplete recovery on Tuesday and opened the database with RESETLOGS option. A user error occurs again on Thursday,whick necessitates an
-
Error when publishing and unable to view SWF
Hi, I am currently working on a project in Flash and I can not publish, test or view the action script. I have around 20 different Flash files that I have created but only 2 work 100% fine. But last week they were all working fine. When I try to open
-
Netflix display error with Safari 8/OSX 10.10 Yosemite
I am having an issue with playing Netflix content through Safari since upgrading to Yosemite. Specifically, Netflix will start to play the content and then display an error after a few seconds. The error reads "Whoops, something went wrong... display