How to execute the CONNECT command in sql
Hi ,
I am using DB2 database and I need to execute the sql statement
CONNECT TO Database user username USING password.
Can anyone tell me how to execute this query in java.
I tried this by using executeQuery but it was giving a sexception somtehing as follows
COM.ibm.db2.jdbc.DB2Exception: [IBM][JDBC Driver] CLI0637E QUERY cannot be found.
at COM.ibm.db2.jdbc.app.SQLExceptionGenerator.throwInvalidQueryError(SQLExceptionGenerator.java:577)
at COM.ibm.db2.jdbc.app.DB2Statement.executeQuery(DB2Statement.java:597)
at First.detail(First.java:18)
at First.main(First.java:29)
can anyone of you help me out in solving this problem
You need a connection to use JDBC stuff. When you have a connection, you are already logged in. There is no need for a query to connect.
Similar Messages
-
How to set the connection parameters for SQL
How to set the connection parameters for SQL to access the MS Access database
Attachments:
Quick_SQL.vi 21 KB
Doc1.doc 45 KB
db1.mdb 112 KBRight-click the WINDOWS desktop, choose New->Microsoft Data Link. That will bring up a dialog that allows you to configure and test your database connection. You might connect to the Access database via ODBC or directly via Jet Engine. The Jet Enginge saves you the trouble of creating an ODBC connection on your PC. After you leave the dialog, the "data link" will show up on your desktop as text file. Open it and copy-paste the connection string to your VI.
This webpage is an excellent resource for connection strings: http://www.able-consulting.com/ADO_Conn.htm
If your application requires users to change the database connection at runtime, you can also include the dialog via ActiveX (MSDASC.IDataSourceLocator). -
How to Execute the row by row sql syntax
Hello,
when I execute the below I get the result as attached, how to execute the syntax in each row, Thanks for your help!
select 'select * into TestSSRS.'+ Table_Name + ' from AdventureWorksDW2008R2.'+ Table_Name FROM [dbo].[Tables_To_Copy]Maybe you could store the value of that field in a string variable using a cursor, i expect you dont need to execute this query very often, because using cursor is not always the best option in data sets.
Regards!
Sergio Sánchez Arias
Oaxaca,México
AYÚDANOS A AYUDARTE -
How to execute the ldapsearch command by java class in linux os?
hi,all
I want to query the users by ldapsearch command. I call the command in my java class. In windows, It work well. But in linux , there haven't any result. My test program is following:
===============
import java.util.*;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.LineNumberReader;
public class test{
public static Vector queryAllUser(){
try{
Vector v=new Vector();
String cmdquery="ldapsearch -h localhost -b\"dc=metasphere,dc=com\" \"uid=*\" uid ";
//String cmdquery="ls -la";
Process process=Runtime.getRuntime().exec(cmdquery);
System.out.println("cmdquery:"+cmdquery);
InputStreamReader ir=new InputStreamReader(process.getInputStream());
LineNumberReader input = new LineNumberReader (ir);
System.out.println("input="+input);
String line;
while ((line = input.readLine ()) != null){
System.out.println("Line:"+line);
if(line.startsWith("uid")){
String temp=line.substring(line.indexOf(":")+1,line.length());
v.add(temp);
return v;
}catch(Exception e){
e.printStackTrace();
System.out.println("runtime error:"+e.getMessage());
return null;
public static void main(String argv[]){
Vector v=queryAllUser();
for(int i=0;i<v.size();i++){
System.out.println((String)v.get(i));
================
In fact, when I execute the command: ldapsearch -h localhost -b"dc=metasphere,dc=com" "uid=*" uid
in linux prompt, the screen show the results:
version: 1
dn: uid=toppymgt,dc=metasphere,dc=com
uid: toppymgt
dn: uid=qutao,dc=metasphere,dc=com
uid: qutao
dn: uid=zz,dc=metasphere,dc=com
uid: zz
dn: uid=z,dc=metasphere,dc=com
uid: z
dn: uid=admin,dc=metasphere,dc=com
uid: admin
dn: uid=alan,dc=metasphere,dc=com
uid: alan
dn: uid=misssixty,dc=metasphere,dc=com
uid: misssixty
dn: uid=channelv,dc=metasphere,dc=com
uid: channelv
What's reason? Please help me. Thx.If there have a bugs in Linux OS. Please help me!
-
How to execute dir dos command in Runtime Execution
Hi All,
Does anybody know how to execute the dir command in DOS in the runtime execution
for example,
when we open the command prompt,
c:\Documents and Settings\java> e:
e:\cd java
e:\dir *.*
how we can list the directory in runtime execution?Process childProcess = Runtime.getRuntime().exec("cmd /C dir *.*");or try with
ProcessBuilder pb = new ProcessBuilder("cmd /C dir *.*");
Process childProcess = pb.start();
NOTE: We can use the ProcessBuilder class from J2SE 5.0+.
for further reference check the below link
http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html?page=3
and don't forget to go through API documentation for java.lang package
http://java.sun.com/j2se/1.5.0/docs/api/java/lang/package-summary.html
and if you want to implement it through Java which provides you a list of Files & directories in the present directory here is an example of such code snippet REF:as insisted by my fellow poster.
File file = new File("<present_directory_path>");
if(file.isDirectory()){
String fileNames[] = file.list();
for(String fileName:fileNames)
System.out.println(fileName);
fileNames = null;
or for detailed info use
File files[] = file.listFiles();
for(File fileEntity:files)
System.out.println("FILENAME:"+fileEntity.getName+",IS FOLDER:"+fileEntity.isFolder()+",ABSOLUTE PATH:"+fileEntity.toString()+"FILE SIZE:"+fileEntity.length());
files = null;
}and please do not forget to go through File API Documentation provided as recommended by my fellow poster.
hope this might help :)
REGARDS,
RaHuL -
How to find the CONNECTION STRING
how to find the connection string through SQL Statement?
salahuddin/salahuddin@CONNECTION_STRING
Below is all about my sql version:
DEFINE SQLPLUSRELEASE = "800060000" (CHAR)
DEFINE _EDITOR = "Notepad" (CHAR)
DEFINE OVERSION = "Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options" (CHAR)
DEFINE ORELEASE = "1002000100" (CHAR)In windows XP plateform your can find from the ServicesHow can you do that using SQL statement? Plus connect strings are not available in Services. In post 9i SQL*Plus we can do it in SQL statement like this
SELECT '&&_CONNECT_IDENTIFIER'
FROM dual;
Note: This will work only in SQL*Plus. -
Error during executing the tp command 'tp Connect DEV...
Dear All,
There is error when I SPAM support package SAPKB70010.(SAP ECC6.0)
Info:
Import phase 'CHECK_REQUIREMENTSS'
\HOSTNAME\SAPMNT\trans\bin\TPPARAM
Error during executing the tp command 'tp connect DEV...'
TP return cod:'0208', tp message:'error in transportprofil (param missing,unknow..'tp output
sapmnt\trans\bin\TPPARAM could not be opened.
EXIT
ERROR:
System: Parameter SAPEVTPATH not set. Batch jobs cannot be started.
Error in
hostname\sapmnt\trans\bin\TPPARAM: transdir not set.
tp return code Summary:
TOOLS:Hightest return code of single steps was:0
ERRORS: Highest tp internal error was:0208
My environment:
Win2003 X64
Oracle 10.2
SAP ECC 6.0 Basis 700 09
Kernel patch num:254
How to solve the issue?
Thank you very much!Hi
2 possible problems.
1) tp is using the wrong profile
2) the profile is not complete
For 1, specify the profile when using the tp command e.g. tp connect dr1
pf='/usr/sap/trans/DR1/bin/TPPARAM'
For 2 you need to edit the TPPARAM file and insert the correct values e.g.
DR1/sapevtpath = /usr/sap/$(system)/SYS/exe/run/sapevt or you can add
it into the command line with the -D option
At the command prompt enter 'tp connect' and the help file will be
displayed for that command with the available options
Cheers
Nirav Kundaria -
How to execute the parametered stored procedure in sql *plus ?
how to execute the parametered stored procedure in sql *plus ?
my storedprocedure format
CREATE OR REPLACE PROCEDURE SMS_SELECTMPLOYEE
(empDOB out date, empEmpName out varchar2)
thanks & regards
mk_murOh, sorry... making many reading-too-fast mistakes today...
You can't declare date variables in SQL*Plus (seel help var), but you can cast to varchar2:
TEST> CREATE OR REPLACE PROCEDURE SMS_SELECTMPLOYEE (empDOB out date, empEmpName out varchar2) IS
2 d date := sysdate;
3 e varchar2(10) := 'bob';
4 begin
5 empdob := d;
6 empempname := e;
7 end;
8 /
Procedure created.
TEST> var d varchar2(30)
TEST> var n varchar2(30)
TEST> call SMS_SELECTMPLOYEE(:d,:n);
Call completed.
TEST> print d n
D
11/07/06
N
bobYoann. -
How to change button names linked with the 'connect command?'
Hi,
I have linked a button in the sequence view to the Exeution entry point 2 (Single Pass) using the 'Connect command'. The button now displays 'Single Pass' as its caption name while running. I want to give a custom name to this button, but it should still be connected to the single pass function. How can rename it?
Regards
GopalHi,
see this link: http://forums.ni.com/ni/board/message?board.id=330&message.id=7318&query.id=380755#M7318
You will find the Text for the buttons in one of the ini files. Use the CustomStrings.ini to define your new text, which will override the text defined in the other ini file located in the NI folder when the Operator Interface or SeqEditor first launched and loads the various resources.
Hope this helps
Regards
Ray Farmer
Regards
Ray Farmer -
How to determine the connection string to a SQLite database, in C# code
Hello. I'm trying to figure out how to specify the connection string to a SQLite database, I would like to access using the following code:
string connectionString = null;
SqlConnection connection;
SqlCommand command;
SqlDataAdapter adapter = new SqlDataAdapter();
DataSet ds1 = new DataSet();
string sql = "SELECT DataName, Data, Id, UserId, DateLastUpdated FROM MainTable";
connectionString = "Data Source=C:\\SQLITEDATABASES\\SQLITEDB1.sqlite;Version=3;";
connection = new SqlConnection(connectionString);
try
connection.Open();
command = new SqlCommand(sql, connection);
catch
The value I assigned to the variable connectionString, in the code above, I obtained somewhere from the Internet. It does not work. I'm using Visual Studio 2013, against the file sqlite-netFx451-setup-bundle-x86-2013-1.0.96.0.exe, which
I installed, and got from
here.
My application's App.config file looks as follows:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
</configSections>
<connectionStrings>
<add name="DC_Password_Saver.Properties.Settings.DC_Password_SaverConnectionString" connectionString="data source="C:\Users\patmo_000\Documents\Visual Studio 2013\Projects\DC Password Saver\DC Password Saver\DC Password Saver.db"" providerName="System.Data.SQLite.EF6"/>
</connectionStrings>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.1"/>
</startup>
</configuration>
I tried to use the value assigned to connectionString in the XML settings above, replacing single backslash characters with double backslash characters, because the Visual Studio editor flagged them as unrecognizable, and wound up with the
following.
SqlDataAdapter adapter = new SqlDataAdapter();
DataSet ds1 = new DataSet();
string sql = "SELECT DataName, Data, Id, UserId, DateLastUpdated FROM MainTable";
connectionString = "data source="C:\\Users\\patmo_000\\Documents\\Visual Studio 2013\\Projects\\DC Password Saver\\DC Password Saver\\DC Password Saver.db"";
connection = new SqlConnection(connectionString);
The above code however does not work either. So again, does anyone know how I can specify in C# code, a connection string to access my SQLite database? Thanks in advance for your reply.What does SQLite connection strings has to do with WPF?
You will find some valid connection strings here:
https://www.connectionstrings.com/sqlite/
But you cannot use the SqlConnection class to connect to a SQLite database. You will need to download and add a reference to the System.Data.SQLite library and then use the SQLiteConnection class:
connection = new System.Data.SQLite.SQLiteConnection(connectionString);
try
connection.Open();
command = new System.Data.SQLite.SQLiteCommand(sql, connection);
catch
Please refer to the following article for more information and an example of how to connect and read and write data from an SQLite database using C#:
http://blog.tigrangasparian.com/2012/02/09/getting-started-with-sqlite-in-c-part-one/.
There is contains a link where you can download the required assemblies.
Hope that helps.
Please remember to mark helpful posts as answer to close your threads and then start a new thread in an approproate forum if you have a new question. -
How to execute the content of varchar variable like a simple query
Hi everyone!
I did a PL/SQL region in apex, in this region I did the query which is storaged in a variable; it was did it concatenate several times,
in the procedure I have several sentences.
I thought that the command 'execute immediate' would get a good result but it do not print the result.
declare
variable varchar2(1000);
begin
--sentences
--execute inmmediate( variable );
--return variable
end;
I only want to how to execute the content of varchar variable.
For example, suppose that the result of this procedure is
'SELECT SYSDATE FROM DUAL'
How and what do I must do for this query execute like a normal query that is in apex?
I expect your prompt reply.
Thank you for your help.
Best regardsLet us say your table containing SQL is
t_sql_table
and has two columns
primary_key
and
sql_query.
You would need to do the following:
1. Create a Report of type "Function returning SQL Query"
2. Put the following there:
DECLARE
v_query VARCHAR2 (4000);
BEGIN
SELECT sql_query
INTO v_query
FROM t_sql_table
WHERE primary_key = 1;
RETURN v_query;
END;Denes Kubicek
http://deneskubicek.blogspot.com/
http://www.opal-consulting.de/training
http://apex.oracle.com/pls/otn/f?p=31517:1
------------------------------------------------------------------- -
How to execute the content of varchar as query
Hi everyone!
I did a PL/SQL region in apex, in this region I did the query which is storaged in a variable; it was did it concatenate several times,
in the procedure I have several sentences.
I thought that the command 'execute immediate' would get a good result but it do not print the result.
declare
variable varchar2(1000);
begin
--sentences
--execute inmmediate( variable );
--return variable
end;
I only want to how to execute the content of varchar variable.
For example, suppose that the result of this procedure is
'SELECT SYSDATE FROM DUAL'
How and what do I must do for this query execute like a normal query that is in apex?
I expect your prompt reply.
Thank you for your help.
Best regardsErik,
Try dropping this into a PL/SQL region
DECLARE
v_result VARCHAR2(500);
BEGIN
SELECT SYSDATE
INTO v_result
FROM DUAL;
htp.prn(v_result);
END;
{code}
use the htp.prn command to write html you want to display. In this case we are just writing the date to the screen.
Good luck,
Tyson -
How to execute a shell command in java?
here, my environment is redhat 7, jdk 1.5.
i don't know how to use the shell command in java.
i want to use this function:
#include <stdlib.h>
int system(const char * string);
please give me some ideas. and Thank you so much if coming with a little demo.i know i should use JNI. because i have to use C lib.
but i have already use JNI to wrapper the original code the cpp code and java code is :
//: appendixb:UseObjImpl.cpp
//# Tested with VC++ & BC++. Include path must
//# be adjusted to find the JNI headers. See
//# the makefile for this chapter (in the
//# downloadable source code) for an example.
#include <jni.h>
#include <stdlib.h>
extern "C" JNIEXPORT void JNICALL
Java_UseObjects_changeObject(
JNIEnv* env, jobject, jobject obj) {
jclass cls = env->GetObjectClass(obj);
jfieldID fid = env->GetFieldID(
cls, "aValue", "I");
jmethodID mid = env->GetMethodID(
cls, "divByTwo", "()V");
int value = env->GetIntField(obj, fid);
printf("Native: %d\n", value);
env->SetIntField(obj, fid, 6);
env->CallVoidMethod(obj, mid);
value = env->GetIntField(obj, fid);
system("preprocess -path sha.c");
printf("Native: %d\n", value);
} ///:~
//: appendixb:UseObjects.java
// From 'Thinking in Java, 2nd ed.' by Bruce Eckel
// www.BruceEckel.com. See copyright notice in CopyRight.txt.
class MyJavaClass {
public int aValue;
public void divByTwo() { aValue /= 2; }
public class UseObjects {
private native void
changeObject(MyJavaClass obj);
static {
// System.loadLibrary("UseObjImpl");
// Linux hack, if you can't get your library
// path set in your environment:
System.load(
"/root/jproj/UseObjImpl.so");
public static void main(String[] args) {
UseObjects app = new UseObjects();
MyJavaClass anObj = new MyJavaClass();
anObj.aValue = 2;
app.changeObject(anObj);
System.out.println("Java: " + anObj.aValue);
} ///:~
i modify this two file which is from TIJ-2edition.
the output is
Native: 2
Native: 3
Java: 3
but what i want to be executed "preprocess -path sha.c" does not work.
i have change the command to, such as "df", "ls" etc. but none of them works
please help me. -
How to test the connection between DSD backend and DSD connector
Dear all,
I am configuring the MDSD scenario .. and i want to insure that my customization is correct
How to test the connection between DSD Backend and DSD connector ??Hi Viren,
The problem is:
We have a new BW system. The basis people asked me to check the connection between this BW system and the R/3. There is only one client for now(100). I have logged into 100 and tried executing RSA1 to check the connection, but it gave a message box saying "You can only work in Client 000". Then I have treid logging into 000(just to make sure) and tried executing RSA1. Even here I got a message saying "The SAP BW system must not be operated in client 000". Now, I am not sure of what is wrong in clien 100. I am not sure if I have to do some settings before I access RSA1 or any other BW transaction. Could you please help me in this.
Also, I just checked the RFC destinations in BW. There is a destination created for our R/3 and I have noticed that they have given a remote UserID and password for remote login. I tried to check the Remote UserID in SU01 but there is no userID with that name. Could this be a problem?
Thanks,
RPK. -
How to restore the Password backup in sql server 2005
How to restore the Password backup in sql server 2005
Hello,
THANKS............ BUT
I executed this query
RESTORE DATABASE new_data1
FROM DISK = 'd:\UK_DETAILS.bak'
with password ='selfinity123'
WITH MOVE 'UK_DETAILS.bak' TO 'D:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\new_data1.mdf',
MOVE 'UK_DETAILS.bak' TO 'D:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\new_data1.ldf'
I got the error
Msg 319, Level 15, State 1, Line 4
Incorrect syntax near the keyword 'with'. If this statement is a common table expression or an xmlnamespaces clause, the previous statement must be terminated with a semicolon.
Maybe you are looking for
-
How to create one user for one workspace
Hi experts, I just wanted to know if anyone of you ever generated a user in a 11g database who only is able to see the content of one specifc workspace. The workflow would be that an admin-like user generates a new workspace and after this he creates
-
Schedule Backup on Oracle Enterprise Manager 10g
Hello All, I am using Oracle enterprise manager 10g for schedule backup, i enter the user and password of operating system (windows XP) in Host Credentials part, but it return this error: Connection to host as user khazaei failed: IOException in send
-
Hey guys, is there a way to transform an XML to a XLS within ABAP? I created an XML object which describes an excel sheet some tables. This XML object i attached to an email for sending. But the created XML is to big (about 20MB). I'd like to transfo
-
Pre installed Adobe Reader LE 1.5.0 on Nokia E71
Hi folks, I am hoping that someone can help me with a small dilema that I have. Last week I updated my E71 firmware to the latest 300.XX. By default the Adobe Reader LE 1.5.0 is installed, but in the applications manager there is no way of removing t
-
Position of a node in an XSLT page
Hi , I am using an xslt page which tells the occurance of a node and am checking if the node is the first or the last node for the last occurance i am aware that it should be position() != last how do we check for the first position ??? Thanks.