How send parameters for Stimulsort - winforms

In my code, I open report and I need that send for they the string connection and string SQL but received error that object
StiReport st = new StiReport(); ((StiSqlDatabase)st.Dictionary.Databases["MySQL"]).ConnectionString = #"Server=XXXXX; Database=XXXXX;UserId = XXXXXX; Pwd = XXXXXX";
((StiSqlSource)st.Dictionary.DataSources["XXXXXXX"]).SqlCommand = "SELECT * FROM xxxxxx";
StiReport st = new StiReport();
st.Load(#"C:\a\Report.mrt");
st.Show();

Related

SOAPUI database connection error[local port 127.0.0.1:4321 cannot be bound]

local port 127.0.0.1:4321 cannot be bound, please see code below for details, note that i am using the lport - 4321. Do i need to use something different? If yes, how can i find one?
package mypackage
import groovy.sql.Sql
import java.sql.*
import com.jcraft.jsch.JSch
import com.jcraft.jsch.Session
// ssh login
String sshHost = 'abc.com'
String sshUser = 'test'
String sshPass = 'test'
int sshPort = 22
String boundaddress ="0.0.0.0";
// database login
targetHost = 'localhost'
targetUser = 'test'
targetPass = 'test'
targetPort = 3306
lport = 4321
JSch jsch = new JSch();
Session session = jsch.getSession(sshUser, sshHost, sshPort);
session.setPassword(sshPass);
session.setConfig("StrictHostKeyChecking", "no");
System.out.println("Establishing Connection...");
session.connect();
int assinged_port=session.setPortForwardingL(lport, targetHost, targetPort);
Connection con = null;
String driver = "org.mariadb.jdbc.Driver";
String connectionString = "jdbc:mariadb://" + targetHost +":" + lport + "/";
con = DriverManager.getConnection(connectionString, targetUser, targetPass);
Statement st = con.createStatement();
String sql = "select * company "
st.execute(sql);

Establish DB connection by using Microsoft OLE DB provider and SQL Native OLE DB provider

I have created a sample app by using both the oledb provider(SQLOLEDB and SQL Native OLEDB provider).
Case 1 : Provider = SQLOLEDB
hr = ::CoInitializeEx(NULL, COINIT_MULTITHREADED);
hr = cADOConnection.CreateInstance(__uuidof(Connection));
CString con_string = "provider=SQLOLEDB;server=MYPC;Database=MyDB";
CString SSlcon_string = "provider=SQLOLEDB;Encrypt=true;TrustServerCertificate=true;server=MYPC;Database=MyDB";
CString userName = "sa";
CString Password = "sa";
BSTR bsConnection = /*con_string*/SSlcon_string.AllocSysString();
BSTR uName = userName.AllocSysString();
BSTR uPassword = Password.AllocSysString();
hr = cADOConnection->Open(bsConnection, uName, uPassword, adConnectUnspecified);
printf("connection has been established");
VARIANT vaNoRecords;
memset(&vaNoRecords, 0, sizeof vaNoRecords);
CString sql = "SELECT * FROM salary";
BSTR query = sql.AllocSysString();
_RecordsetPtr rs;
rs = cADOConnection->Execute(query, &vaNoRecords, adCmdText);
printf("connection has been established\n");
Result : If certificate is installed on server machine then the connection is secure regardless of enabling
Encrypt=true and TrustServerCertificate=true from in connection string.
Case 2 : Provider = SQLNCLI10.1(SQL native client oledb provider)
HRESULT hr;
hr = ::CoInitializeEx(NULL, COINIT_MULTITHREADED);
hr = cADOConnection.CreateInstance(__uuidof(Connection));
CString con_string = "provider=SQLNCLI10.1;server=MYPC;Database=MyDB";
CString SSlcon_string = "provider=SQLOLEDB;Encrypt=true;TrustServerCertificate=true;server=MYPC;Database=MyDB";
CString userName = "sa";
CString Password = "sa";
BSTR bsConnection = con_string/*SSlcon_string*/.AllocSysString();
BSTR uName = userName.AllocSysString();
BSTR uPassword = Password.AllocSysString();
hr = cADOConnection->Open(bsConnection, uName, uPassword, adConnectUnspecified);
printf("connection has been established");
VARIANT vaNoRecords;
memset(&vaNoRecords, 0, sizeof vaNoRecords);
CString sql = "SELECT suppliernumber, name1 FROM zrs_supplier";
BSTR query = sql.AllocSysString();
_RecordsetPtr rs;
rs = cADOConnection->Execute(query, &vaNoRecords, adCmdText);
printf("connection has been established\n");
Result : If certificate is installed on server machine then the connection is secure regardless of enabling
Encrypt=true and TrustServerCertificate=true from in connection string.i.e Result is same as above.
In both the case i am getting same behavior.Am i missing something here??
Any Suggestion would be appreciated ??
Original question
Replace the connection string with
CString SSlcon_string = "provider=SQLOLEDB;Use Encryption for Data=True;server=MYPC;Database=MyDB";
The remaining steps will be same.Install the same certificate(present on server) on client machine's "truted root certificate authorities" folder.
If server and client both will have same certificate then connection will be established(SSL Connection) otherwise fail.

String or binary data would be truncated when updating datatable

I am trying to update customer info. I use this code to load 5 fields:
cust_cn.Open()
Dim cust_da As New SqlDataAdapter("SELECT * FROM [customers] where [custID]=" & txtCustPhone.Text, cust_cn)
cust_da.Fill(cust_datatable)
txtCustPhone.Text = cust_datatable.Rows(0).Item("custID")
txtCustFirstName.Text = cust_datatable.Rows(0).Item("first")
txtCustLastName.Text = cust_datatable.Rows(0).Item("last")
txtCustAddress.Text = cust_datatable.Rows(0).Item("address")
txtCustZip.Text = cust_datatable.Rows(0).Item("zip")
and this works fine. When I try to modify one of the fields (change zip code on an existing customer)
with this code:
If cust_datatable.Rows.Count <> 0 Then
cust_datatable.Rows(0).Item("custID") = txtCustPhone.Text
cust_datatable.Rows(0).Item("first") = txtCustFirstName.Text
cust_datatable.Rows(0).Item("last") = txtCustLastName
cust_datatable.Rows(0).Item("address") = txtCustAddress.Text
cust_datatable.Rows(0).Item("zip") = txtCustZip.Text
'cust_datatable.Rows(custrecord)("custID") = txtCustPhone.Text
'cust_datatable.Rows(custrecord)("first") = txtCustFirstName.Text
'cust_datatable.Rows(custrecord)("last") = txtCustLastName.Text
'cust_datatable.Rows(custrecord)("address") = txtCustAddress.Text
'cust_datatable.Rows(custrecord)("zip") = txtCustZip.Text
cust_DA.Update(cust_datatable)
End If
I get the error: "String or binary data would be truncated"
I originally tried to update using the commented section, but it was only modifying the first record in the database.
Any thoughts?

"Data source name not found" when using unixODBC connection

I am getting this error from views.py:
('IM002', '[IM002] [unixODBC][Driver Manager]Data source name not
found, and no default driver specified (0) (SQLDriverConnectW)')
Here is views.py to save the database data to a json file
connstr = 'DRIVER={SQL Server};SERVER=dev_appserver;DATABASE=DemoApp;'
conn = pyodbc.connect(connstr)
cursor = conn.cursor()
cursor.execute("""
SELECT book_id, book_name, author_name, publisher_name, email, bookref
FROM Book
""")
rows = cursor.fetchall()
rowarray_list = []
for row in rows:
t = (row.book_id, row.book_name, row.author_name, row.publisher_name,
row.email, row.bookref)
rowarray_list.append(t)
j = json.dumps(rowarray_list)
rowarrays_file = 'student_rowarrays.json'
f = open(rowarrays_file,'w')
print >> f, j
objects_list = []
for row in rows:
d = collections.OrderedDict()
d['book_id'] = row.book_id
d['book_name'] = row.book_name
d['author_name'] = row.author_name
d['publisher_name'] = row.publisher_name
d['email'] = row.email
d['bookref'] = row.bookref
objects_list.append(d)
j = json.dumps(objects_list)
objects_file = 'student_objects.json'
f = open(objects_file,'w')
print >> f, j
conn.close()
This is coded to write the database data to a json file
Thanks
You don't appear to be passing a username or password when you connect to the database.
Try something like this:
connstr = 'DRIVER={SQL Server};SERVER=dev_appserver;DATABASE=DemoApp;UID=username;PWD=password'
conn = pyodbc.connect(connstr)

Data encryption issues with Oracle Advanced Security

I have used Oracle Advanced Security to encrypt data during data transfer. I have successfully configured ssl with below parameters and I have restarted the instance. I am retrieving data from a Java class given below. But I could read the data without decrypting, the data is not getting encrypted.
Environment:
Oragle 11g database
SQLNET.AUTHENTICATION_SERVICES= (BEQ, TCPS, NTS)
SSL_VERSION = 0
NAMES.DIRECTORY_PATH= (TNSNAMES, EZCONNECT)
SSL_CLIENT_AUTHENTICATION = FALSE
WALLET_LOCATION =
(SOURCE =
(METHOD = FILE)
(METHOD_DATA =
(DIRECTORY = C:\Users\kcr\Oracle\WALLETS)
)
)
SSL_CIPHER_SUITES= (SSL_RSA_EXPORT_WITH_RC4_40_MD5)
Java class:
try{
Properties properties = Utils.readProperties("weka/experiment/DatabaseUtils.props");
// Security.addProvider(new oracle.security.pki.OraclePKIProvider()); //Security syntax
String url = "jdbc:oracle:thin:#(DESCRIPTION =\n" +
" (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))\n" +
" (CONNECT_DATA =\n" +
" (SERVER = DEDICATED)\n" +
" (SERVICE_NAME = sal)\n" +
" )\n" +
" )";
java.util.Properties props = new java.util.Properties();
props.setProperty("user", "system");
props.setProperty("password", "weblogic");
// props.setProperty("javax.net.ssl.trustStore","C:\\Users\\kcr\\Oracle\\WALLETS\\ewallet.p12");
// props.setProperty("oracle.net.ssl_cipher_suites","SSL_RSA_EXPORT_WITH_RC4_40_MD5");
// props.setProperty("javax.net.ssl.trustStoreType","PKCS12");
//props.setProperty("javax.net.ssl.trustStorePassword","welcome2");
DriverManager.registerDriver(new OracleDriver());
Connection conn = DriverManager.getConnection(url, props);
/*8 OracleDataSource ods = new OracleDataSource();
ods.setUser("system");
ods.setPassword("weblogic");
ods.setURL(url);
Connection conn = ods.getConnection();*/
Statement stmt = conn.createStatement();
ResultSet rset = stmt.executeQuery("select * from iris");
///////////////////////////
while(rset.next()) {
for (int i=1; i<=5; i++) {
System.out.print(rset.getString(i));
}
}
Are you expecting that your SELECT statement would return encrypted data and that your System.out.print calls would result in encrypted output going to the screen? If so, that's not the way advanced security works-- Advanced Security allows you to encrypt data over the wire but the data is unencrypted in the SQLNet stack. Your SELECT statement, therefore, would always see the data in an unencrypted state. You would need to do a SQLNet trace or use some sort of packet sniffer to see the encrypted data flowing over the wire.
You'll find the documentation in "SSL With Oracle JDBC Thin Driver".
In particular you should probably use PROTOCOL = TCPS instead of PROTOCOL = TCP. I'd also suggest using a stronger cipher suite (and avoid the anonymous ones, since with them you don't verify the identity of the remote server).

Resources