I am trying to figure out how to connect to an IBM informix database. I have been doing some research and have found some threads from 5 years ago but those examples are not working.
I have installed the latest SDK from IBM for informix.
I have included the IBM.Data.Informix.dll to my references in my project.
I have included the using IBM.Data.Informix;
I am just adding a button and on click testing the conenction. I always get this debug error
"SQL0035N The file "C:\Users\Adam\documents\visual studio 2010\Projects\test\test\msg\en_US\db2nmp.xml" cannot be opened."
This file does not exist and I dont see it anywhere in the Program Files (x86)\IBM Informix Client SDK directory.
My On click code is
private void button1_Click(object sender, EventArgs e)
{
const string HOST = "192.168.OBFUSCATED";
const string SERVICENUM = "1525"; //Port?
const string SERVER = "serverOBFUSCATED";
const string DATABASE = "dbOBFUSCATEDy";
const string USER = "myusername";
const string PASSWORD = "mypassword";
string ConnectionString = "Host=" + HOST + "; " +
"Service=" + SERVICENUM + "; " +
"Server=" + SERVER + "; " +
"Database=" + DATABASE + "; " +
"User Id=" + USER + "; " +
"Password=" + PASSWORD + "; ";
IfxConnection conn = new IfxConnection();
conn.ConnectionString = ConnectionString;
try
{
conn.Open();
MessageBox.Show("Made connection!");
}
catch (IfxException ex)
{
MessageBox.Show("Problem with connection attempt: " + ex.Message);
}
}
Anyone know what I am doing wrong or the current best way to connect to informix database?
Thanks in advance.
Check your version of informix.
What you need is a connector compatible with your version of informix database installed.
check this:
http://www.ibm.com/developerworks/data/library/techarticle/dm-1007dsnetids/index.html
I was experiencing the same error, try to form your string with the following format:
string ConnectionString = "Server=" + HOST + ":" + SERVICENUM + "; " +
"Database=" + SERVER + "\" + DATABASE + "; " +
"User Id=" + USER + "; " +
"Password=" + PASSWORD + "; ";
The result, using the values from your example, should be:
"Server=192.168.OBFUSCATED:1525;Database=serverOBFUSCATED\dbOBFUSCATEDy;User ID=myusername;Password=mypassword;"
Related
I am using Spring Boot and PostgreSQL to create a table in which I want to insert the latest data from another table.
I was using H2 and everything was fine but when I migrated to PostgreSQL, the error "SELECT ... FROM must be followed by a reference to the table appeared e.g. SELECT * FROM table as FOO" .
However, when modifying my query with AS, I am still having the same error.
"CREATE TABLE IF NOT EXISTS EOD AS " +
"(SELECT ID, " +
"CUSIP, " +
"NAME, " +
"ISIN, " +
"NAV, " +
"RIC, " +
"RTV," +
"VOLATILITY as volatility, " +
"CURRENCY as currency, "+
"ASK_ISSUER as ask_issuer, " +
"ASK_KECH as ask_kech, " +
"AVERAGE_SCORE as average_score, " +
"BID_ISSUER as bid_issuer, " +
"BID_KECH as bid_kech, " +
"BID_ONLY as bid_only, " +
"CREATOR as creator, " +
"DECENTER as decenter, " +
"DENOMINATION as denomination, " +
"FORCE_PUBLISH as force_publish, " +
"ISSUER_SPREAD as issuer_spread, " +
"KECH_MARGIN as kech_margin, " +
"KECH_SPREAD as kech_spread, " +
"DISTANCE_TO_BANDS_SCORE as distance_to_bands_score, " +
"DIFFERENCE_TO_LEXIFI_PRICE_SCORE as difference_to_lexifi_price_score, " +
"METRIC_C as metric_c, " +
"PRICE_EXPRESSION as price_expression, " +
"PRODUCT_TYPE as product_type, " +
"PUBLISHED as published, " +
"PUBLISHING as publishing, " +
"TIMESTAMP as timestamp " +
"FROM " +
"(" +
"SELECT * FROM RTDATABASE AS T " +
"JOIN (SELECT MAX(CONVERT(TIMESTAMP, DATETIME)) AS LATESTDATE FROM T GROUP BY ISIN)" +
") tm " +
"WHERE CONVERT(tm.TIMESTAMP, DATETIME) = tm.LATESTDATE) AS LATESTDATA;";
Any idea how to solve this issue?
Many thanks in advance !
I successfully create and execute a flexiblesearch query with a WHERE clause comparing a custom property, added to CartModel, with a enum value.
But I don't know how to "translate" it to try on HAC (just to try and fix it before coding inside a class).
In my class I've the working code:
String MY_QUERY = "SELECT {" + CartModel.PK + "} FROM {" + CartModel._TYPECODE + "} "
+ "WHERE " + "( {" + CartModel.RESERVATIONORDERSTATUS + "} = ?reservedOnHybris)";
And I set the reservedOnHybris parameter with
searchQuery.addQueryParameter("reservedOnHybris", ReservationOrderStatus.INITIAL_STATUS);
How can I translate this to try it on the FlexibleSearch panel in the HAC?
Thanks in advance.
Ale
This should work:
String MY_QUERY = "SELECT {" + CartModel.PK + "} FROM {" + CartModel._TYPECODE + "} "
+ "WHERE " + "( {" + CartModel.RESERVATIONORDERSTATUS + "} =
({{SELECT {crse.PK} FROM {" + CartReservationStatusEnum._TYPECODE
+ " as crse} WHERE {crse.code} = '" + ?reservedOnHybris + "'}}))"
You should get the PK of your enum, you could do this by using a select query.
Try :
SELECT {PK} FROM {Cart} WHERE {RESERVATIONORDERSTATUS} = "Your status"
Basically things like "CartModel.PK" could be replaced by the String.
var timer = {display:'x', at:'12/23/2016', in : 3000000};
var text = timer.display + " on " + timer.at + ". Time Remaining : " + timer.in;
throws error in IE8 "Expected identifier, string or number"
var text = timer.display + " on " + timer.at + ". Time Remaining : " + timer['in']; works!!!
This works fine in chrome, is .in a keyword and why only IE8 behaving weird?
Isn't in considered as a keyword? You could use:
var timer = {"display":"x", "at":"12/23/2016", "in" : "3000000"};
var text = timer.display + " on " + timer.at + ". Time Remaining : " + timer["in"];
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Lexical_grammar#Keywords
Solution:
Use CultureInfo.CurrentUICulture
User can change the system language of Windows Phone at:
Settings > language+region > Phone language
How can I get the selected language (Phone language) from C# code?
Below is my phone settings:
Here is my code snippet:
System.Diagnostics.Debug.WriteLine(
"************************************* CultureInfo.CurrentCulture.Name = " + CultureInfo.CurrentCulture.ToString() + ", " +
"CultureInfo.CurrentCulture.CompareInfo = " + CultureInfo.CurrentCulture.CompareInfo + ", " +
"CultureInfo.CurrentCulture.DisplayName = " + CultureInfo.CurrentCulture.DisplayName + ", " +
"CultureInfo.CurrentCulture.EnglishName = " + CultureInfo.CurrentCulture.EnglishName + ", " +
"CultureInfo.CurrentCulture.Name = " + CultureInfo.CurrentCulture.Name + ", " +
"CultureInfo.CurrentCulture.NativeName = " + CultureInfo.CurrentCulture.NativeName + ", " +
"CultureInfo.CurrentCulture.TextInfo = " + CultureInfo.CurrentCulture.TextInfo
);
Here is the output:
CultureInfo.CurrentCulture.Name = zh-HK,
CultureInfo.CurrentCulture.CompareInfo = CompareInfo - zh-HK,
CultureInfo.CurrentCulture.DisplayName = Chinese (Traditional, Hong
Kong SAR), CultureInfo.CurrentCulture.EnglishName = Chinese
(Traditional, Hong Kong SAR), CultureInfo.CurrentCulture.Name = zh-HK,
CultureInfo.CurrentCulture.NativeName = 中文(香港特別行政區),
CultureInfo.CurrentCulture.TextInfo = TextInfo - zh-HK
I cannot find the 'Phone Language'
Use System.Threading.Thread.CurrentThread.CurrentCulture. It should correctly reflect the phone language.
you can check my answer, this will help you to change the language at runtime:
https://stackoverflow.com/a/17131401/2467917
I have an update query in a servlet. The syntax is is correct, but when I execute the query, nothing happens. The execution stays frozen and the command never ends. Minutes later the message "ADVERTENCIA: GRIZZLY0023: Interrupting idle Thread: http-thread-pool-8080(5)." is printed every couple of seconds
I have tried with:
con.stmt.executeUpdate ("SQL");
con.rset = con.stmt.executeQuery ("SQL");
and with PreparedStatement.
This is the query:
System.out.println(""
+ " UPDATE JSP_TABLE SET "
+ " field1 = '" + request.getParameter("input1") + "',"
+ " field2= '" + request.getParameter("input2") + "',"
+ " field3= '" + request.getParameter("input3") + "',"
+ " field4= '" + request.getParameter("input4") + "',"
+ " field5= '" + request.getParameter("input5") + "',"
+ " field6= '" + request.getParameter("input6") + "',"
+ " field7= '" + request.getParameter("input7") + "',"
+ " field8= '" + indicador + " VS " + request.getParameter("input8") + "',"
+ " field9= '" + request.getParameter("input") + " al " + request.getParameter("hasta9") + "'"
+ " WHERE ID_PK = " + request.getParameter("inputPK"));
All my Statements, ResultSets and Connections are closed at the end of use.
I have a second update which works fine.
package Funciones;
import conexion.conectar;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class ActualizarDinamica extends HttpServlet {
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException, SQLException {
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
conectar con = new conectar();
try {
/*
* TODO output your page here. You may use following sample code.
*/
con.stmt = con.conn.createStatement();
String indicador = "";
switch (Integer.parseInt(request.getParameter("indicador"))) {
case 1:
indicador = "Nivel de Servicio";
break;
case 2:
indicador = "Venta";
break;
case 3:
indicador = request.getParameter("txt_otro");
break;
case 0:
indicador = "Presencia";
break;
};
/* way 1
* con.rset = con.stmt.executeQuery(""
+ " UPDATE JSP_TABLE SET "
+ " FIELD1 = '" + request.getParameter("input1") + "',"
+ " FIELD2 = '" + request.getParameter("input2") + "',"
+ " FIELD3 = '" + request.getParameter("input3") + "',"
+ " FIELD4 = '" + request.getParameter("input4") + "',"
+ " FIELD5 = '" + request.getParameter("input5") + "',"
+ " FIELD6 = '" + request.getParameter("input6") + "',"
+ " FIELD7 = '" + request.getParameter("input7") + "',"
+ " FIELD8 = '" + indicador + " VS " + request.getParameter("input8") + "',"
+ " FIELD9 = '" + request.getParameter("input9") + " al " + request.getParameter("input10") + "'"
+ " WHERE FIELD_PK = " + request.getParameter("input11_ID"));
con.rset = con.stmt.executeQuery(""
+ " UPDATE JSP_TABLE2 SET"
+ " FIELD_DATE = TO_DATE('" + request.getParameter("input12") + " " + request.getParameter("input14") + ":" + request.getParameter("input13") + "','DD/MM/YYYY HH24:MI')"
+ " WHERE FIELD_ID = " + request.getParameter("input11_ID"));
*/
/* way 2
con.stmt.executeUpdate(""
+ " UPDATE JSP_TABLE SET "
+ " FIELD1 = '" + request.getParameter("input1") + "',"
+ " FIELD2 = '" + request.getParameter("input2") + "',"
+ " FIELD3 = '" + request.getParameter("input3") + "',"
+ " FIELD4 = '" + request.getParameter("input4") + "',"
+ " FIELD5 = '" + request.getParameter("input5") + "',"
+ " FIELD6 = '" + request.getParameter("input6") + "',"
+ " FIELD7 = '" + request.getParameter("input7") + "',"
+ " FIELD8 = '" + indicador + " VS " + request.getParameter("input8") + "',"
+ " FIELD9 = '" + request.getParameter("input9") + " al " + request.getParameter("input10") + "'"
+ " WHERE FIELD_PK = " + request.getParameter("input11_ID"));
con.stmt.executeUpdate(""
+ " UPDATE JSP_TABLE2 SET"
+ " FIELD_DATE = TO_DATE('" + request.getParameter("input12") + " " + request.getParameter("input14") + ":" + request.getParameter("input13") + "','DD/MM/YYYY HH24:MI')"
+ " WHERE FIELD_ID = " + request.getParameter("input11_ID"));
*/
//way 3
PreparedStatement updateSmallQuery = null;
PreparedStatement updateBigQuery = null;
String bigQuery=
""
+ " UPDATE JSP_TABLE SET "
+ " FIELD1 = '" + request.getParameter("input1") + "',"
+ " FIELD2 = '" + request.getParameter("input2") + "',"
+ " FIELD3 = '" + request.getParameter("input3") + "',"
+ " FIELD4 = '" + request.getParameter("input4") + "',"
+ " FIELD5 = '" + request.getParameter("input5") + "',"
+ " FIELD6 = '" + request.getParameter("input6") + "',"
+ " FIELD7 = '" + request.getParameter("input7") + "',"
+ " FIELD8 = '" + indicador + " VS " + request.getParameter("input8") + "',"
+ " FIELD9 = '" + request.getParameter("input9") + " al " + request.getParameter("input10") + "'"
+ " WHERE FIELD_PK = " + request.getParameter("input11_ID");
String smallQuery= ""
+ " UPDATE JSP_TABLE2 SET"
+ " FIELD_DATE = TO_DATE('" + request.getParameter("input12") + " " + request.getParameter("input14") + ":" + request.getParameter("input13") + "','DD/MM/YYYY HH24:MI')"
+ " WHERE FIELD_ID = " + request.getParameter("input11_ID");
try {
con.conn.setAutoCommit(false);
updateSmallQuery = con.conn.prepareStatement(smallQuery);
updateBigQuery = con.conn.prepareStatement(bigQuery);
updateBigQuery.executeUpdate();
updateSmallQuery.executeUpdate();
con.conn.commit();
} catch (SQLException e) {
System.out.println("catch!");
System.out.println(e.getMessage());
if (con != null) {
try {
System.err.print("Transaction is being rolled back");
con.conn.rollback();
} catch (SQLException excep) {
}
}
} finally {
if (updateSmallQuery != null) {
updateSmallQuery.close();
}
if (updateBigQuery != null) {
updateBigQuery .close();
}
con.conn.setAutoCommit(true);
}
response.sendRedirect("sol_env_c.jsp");
} finally {
con.conn.commit();
con.conn.close();
con.stmt.close();
out.close();
}
}
}
Hope this help to find the answer.
PD: The small one run with no problems. the big one it's the problem.
EDIT:
This is conectar()
public conectar() {
try {
Class.forName("oracle.jdbc.OracleDriver");
System.out.println("Oracle JDBC driver loaded ok.");
conn = DriverManager.getConnection(params, user, password);
} catch (Exception e) {
System.err.println("Exception: " + e.getMessage());
}
}
Bill is almost certainly correct and you just have a lock on rows you're trying to update. You mentioned that 'the syntax is correct', which suggests you might have checked it directly in the database - e.g. with SQL*Plus or SQL Developer - and have not issued a rollback (or commit) in that session. Attempting to update the same rows from your code is then hanging waiting for the locks to be released.
If you can find the session where you ran the update manually, issue a rollback in it. If you can't, you can see which sessions are holding locks with a query like:
select vs.osuser, vs.process, vs.logon_time, vs.sid, vs.serial#, vs.program,
dl.lock_type, dl.mode_held, dl.blocking_others
from dba_locks dl
left join v$session vs on vs.sid = dl.session_id
where lock_type != 'Media Recovery'
and lock_type != 'Redo Thread';
While your code is running - and hung - you can see what's blocking it with something like:
select vsw.osuser, vsw.process, vsw.logon_time, vsw.sid, vsw.program,
dw.lock_type, dw.mode_held,
vsh.osuser, vsh.process, vsh.logon_time, vsh.sid, vsh.serial#, vsh.program
from dba_waiters dw
left join v$session vsw on vsw.sid = dw.waiting_session
left join v$session vsh on vsh.sid = dw.holding_session;
Or search for other examples, e.g. this. You need privileges to query the v$ performance views, and if you don't have them you may need DBA assistance. If you can't manually rollback the lock you might need DBA help to kill the locking session anyway.
You should really pay attention to the comments about parameterising your statements, too.