Search Results

Search found 214 results on 9 pages for 'executequery'.

Page 1/9 | 1 2 3 4 5 6 7 8 9  | Next Page >

  • Using ExecuteQuery() with entity framework, entity class.

    - by sfreelander
    I am trying to jump from ASP Classic to asp.net. I have followed tutorials to get Entity Framework and LINQ to connect to my test database, but I am having difficulties figuring out ExecuteQuery(). I believe the problem is that I need an "entity class" for my database, but I can't figure out how to do it. Here is my simple code: Dim db as New TestModel.TestEntity Dim results AS IEnumerable(OF ???) = db.ExecuteQuery(Of ???)("Select * from Table1") From the microsoft example site, they use an entity class called Customers, but I don't understand what that means.

    Read the article

  • LINQ-to-SQL: ExecuteQuery(Type, String) populates one field, but not the other

    - by Daniel Schaffer
    I've written an app that I use as an agent to query data from a database and automatically load it into my distributed web cache. I do this by specifying an sql query and a type in a configuration. The code that actually does the querying looks like this: List<Object> result = null; try { result = dc.ExecuteQuery(elementType, entry.Command).OfType<Object>().ToList(); } catch (Exception ex) { HandleException(ex, WebCacheAgentLogEvent.DatabaseExecutionError); continue; } elementType is a System.Type created from the type specified in the configuration (using Type.GetType()), and entry.Command is the SQL query. The specific entity type I'm having an issue with looks like this: public class FooCount { [Column(Name = "foo_id")] public Int32 FooId { get; set; } [Column(Name = "count")] public Int32 Count { get; set; } } The SQL query looks like this: select foo_id as foo_id, sum(count) as [count] from foo_aggregates group by foo_id order by foo_id For some reason, when the query is executed, the "Count" property ends up populated, but not the "FooId" property. I tried running the query myself, and the correct column names are returned, and the column names match up with what I've specified in my mapping attributes. Help!

    Read the article

  • Can not issue data manipulation statements with executeQuery in java

    - by user225269
    I'm trying to insert records in mysql database using java, What do I place in this code so that I could insert records: String id; String name; String school; String gender; String lang; Scanner inputs = new Scanner(System.in); System.out.println("Input id:"); id=inputs.next(); System.out.println("Input name:"); name=inputs.next(); System.out.println("Input school:"); school= inputs.next(); System.out.println("Input gender:"); gender= inputs.next(); System.out.println("Input lang:"); lang=inputs.next(); Class.forName("com.mysql.jdbc.Driver"); Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/employee_record", "root", "MyPassword"); PreparedStatement statement = con.prepareStatement("insert into employee values('id', 'name', 'school', 'gender', 'lang');"); statement.executeUpdate();

    Read the article

  • LINQ to SQL: ExecuteQuery not working when performing a parameterized query.

    - by ajbeaven
    I have a weird problem with ExecuteQuery in that it isn't working when performing a parameterized query. The following returns 1 record: db.ExecuteQuery<Member>(@"SELECT * FROM Member INNER JOIN aspnet_Users ON Member.user_id = aspnet_Users.UserId WHERE [aspnet_Users].[UserName] = 'Marina2'"); However, the parameterized version returns no results: db.ExecuteQuery<Member>(@"SELECT * FROM Member INNER JOIN aspnet_Users ON Member.user_id = aspnet_Users.UserId WHERE [aspnet_Users].[UserName] = '{0}'", "Marina2"); What am I doing wrong?

    Read the article

  • lambda expressions in VB.NET... what am I doing wrong???

    - by Bob
    when I run this C# code, no problems... but when I translate it into VB.NET it compiles but blows due to 'CompareString' member not being allowed in the expression... I feel like I'm missing something key here... private void PrintButton_Click(object sender, EventArgs e) { if (ListsListBox.SelectedIndex > -1) { //Context using (ClientOM.ClientContext ctx = new ClientOM.ClientContext(UrlTextBox.Text)) { //Get selected list string listTitle = ListsListBox.SelectedItem.ToString(); ClientOM.Web site = ctx.Web; ctx.Load(site, s => s.Lists.Where(l => l.Title == listTitle)); ctx.ExecuteQuery(); ClientOM.List list = site.Lists[0]; //Get fields for this list ctx.Load(list, l => l.Fields.Where(f => f.Hidden == false && (f.CanBeDeleted == true || f.InternalName == "Title"))); ctx.ExecuteQuery(); //Get items for the list ClientOM.ListItemCollection listItems = list.GetItems( ClientOM.CamlQuery.CreateAllItemsQuery()); ctx.Load(listItems); ctx.ExecuteQuery(); // DOCUMENT CREATION CODE GOES HERE } MessageBox.Show("Document Created!"); } } but in VB.NET code this errors due to not being allowed 'CompareString' members in the ctx.Load() methods... Private Sub PrintButton_Click(sender As Object, e As EventArgs) If ListsListBox.SelectedIndex > -1 Then 'Context Using ctx As New ClientOM.ClientContext(UrlTextBox.Text) 'Get selected list Dim listTitle As String = ListsListBox.SelectedItem.ToString() Dim site As ClientOM.Web = ctx.Web ctx.Load(site, Function(s) s.Lists.Where(Function(l) l.Title = listTitle)) ctx.ExecuteQuery() Dim list As ClientOM.List = site.Lists(0) 'Get fields for this list ctx.Load(list, Function(l) l.Fields.Where(Function(f) f.Hidden = False AndAlso (f.CanBeDeleted = True OrElse f.InternalName = "Title"))) ctx.ExecuteQuery() 'Get items for the list Dim listItems As ClientOM.ListItemCollection = list.GetItems(ClientOM.CamlQuery.CreateAllItemsQuery()) ctx.Load(listItems) ' DOCUMENT CREATION CODE GOES HERE ctx.ExecuteQuery() End Using MessageBox.Show("Document Created!") End If End Sub

    Read the article

  • Sorting: TransientVO Vs Query/EO based VO

    - by Vijay Mohan
    In ADF, you can do a sorting on VO rows by invoking setSortBy("VOAttrName") API, but the tricky part is that, this API actually appends a clause to VO query at runtime and the actual sorting is performed after doing VO.executeQuery(), this goes fine for Query/EO based VO. But, how about the transient VO, wherein the rows are populated programmatically..?There is a way to it..:)you can actually specify the query mode on your transient VO, so that the sorting happens on already populated VO rows.Here are the steps to go about it..//Populate your transient VO rows.//VO.setSortBy("YourVOAttrName");//VO.setQueryMode(ViewObject.QUERY_MODE_SCAN_VIEW_ROWS);//VO.executeQuery();So, here the executeQuery() is actually the trigger which calls for VO rows sorting.QUERY_MODE_SCAN_VIEW_ROWS flag makes sure that the sorting is performed on the already populated VO cache.

    Read the article

  • select for update problem in jdbc

    - by kartiku
    I'm having a problem with select for update in jdbc. The table i'm trying to update is the smalldb table, i'm having problems-- i'm using select for update which does a lock on the selected row the update statement is -- String updateQ = "UPDATE libra.smalldb SET hIx = ? WHERE name = ?"; the select statement is -- rs = stmt1.executeQuery("SELECT hIx FROM libra.smalldb for update"); rs0 = stmt2.executeQuery("SELECT name,aff FROM libra.smalldb"); the second statement is because i need those fields as well. Here is the complete code -- import java.sql.*; import java.util.ArrayList; import java.util.Collections; public class Jdbcexample1 { /** * @param args */ public static void main(String[] args) { Connection con = null; try { Class.forName("com.mysql.jdbc.Driver").newInstance(); con = DriverManager.getConnection("jdbc:mysql:///test", "root", "*****"); //String url = "jdbc:msql://200.210.220.1:1114/Demo"; //Connection conn = DriverManager.getConnection(url,"",""); Statement stmt1 = con.createStatement(); Statement stmt2 = con.createStatement(); Statement stmt3 = con.createStatement(); Statement stmt4 = con.createStatement(); ResultSet rs0; ResultSet rs; ResultSet rs1; ResultSet rs2; String name; String hIx; int hIxInt; StringBuffer sb = new StringBuffer(); String affiliationSmall; ArrayList<String> affiliation = new ArrayList<String>(); ArrayList<Float> matchValues = new ArrayList<Float>(); ArrayList<Integer> hixValues = new ArrayList<Integer>(); ArrayList<Integer> idValues = new ArrayList<Integer>(); boolean moreFlag = false; String queryString; int tmpIdx; String name1; //get the hix at that index where the similarity is maximum int tmpHidx = 0; int tmpHix = 0; int id = 0; int count; int tmpidIdx = 0; //rs = stmt.executeQuery("SELECT id FROM libra.researchint WHERE id = 910887"); // Get name, affiliation , hIx from smalldb //rs = stmt1.executeQuery("SELECT name,aff,hIx FROM libra.smalldb"); // String cursorName = "OUR_CURSOR"; // stmt1.setCursorName(cursorName); //rs = stmt1.executeQuery("SELECT name,aff,hIx FROM libra.smalldb for update"); rs = stmt1.executeQuery("SELECT hIx FROM libra.smalldb for update"); rs0 = stmt2.executeQuery("SELECT name,aff FROM libra.smalldb"); while ( rs.next() && rs0.next() ) { //String lastName = rs.getString("id"); hIx = rs.getString("hIx"); hIxInt = Integer.parseInt(hIx); //if hIx if (hIxInt==-1) continue; //name = rs.getString("name"); name = rs0.getString("name"); name1 = new String(name); System.out.println(name); //affiliationSmall = rs.getString("aff"); affiliationSmall = rs0.getString("aff"); //name = "\"" +name+ "\""; // Get matching names from large faculty table //String queryString = "SELECT id,name,hIx FROM libra.faculty WHERE name = " +name; //name = does not work names are similar but not same (in faculty and // smalldb) String query = "SELECT id,name,hIx FROM libra.faculty WHERE name like ?"; //String query = "SELECT id,name,hIx FROM libra.faculty for update of hIx WHERE name like ?"; PreparedStatement prepStmt = con.prepareStatement(query); String[] nameArr = name.split(" "); StringBuffer tmpSb = new StringBuffer(); for(int idx = 0;idx<nameArr.length;idx++) { tmpSb.append(nameArr[idx] + "%"); } name = tmpSb.toString(); prepStmt.setString(1, name); rs1 = prepStmt.executeQuery(); //Try to get matching names from faculty big db //Execute the query on faculty table //rs1 = stmt2.executeQuery(queryString); if(rs1.isClosed()) continue; count = 0; matchValues.clear(); affiliation.clear(); while(rs1.next()) { //name = rs1.getString("name"); id = Integer.parseInt(rs1.getString("id")); //idValues.add(id); tmpHix = Integer.parseInt(rs1.getString("hIx")); queryString = "SELECT aff FROM libra.affiliation WHERE id = "+id; rs2 = stmt3.executeQuery(queryString); //affiliation = rs1.getString("aff"); sb.delete(0, sb.length()); while (rs2.next()) { //Concatenate it to the same string using a stringbuffer sb.append(rs2.getString("aff")); //affiliation.add(rs2.getString("aff")); } affiliation.add(sb.toString()); count++; // if(count1) // { // moreFlag = true; // //Call fuzzy match function, store the distance values and select the // //affiliation that has the minimum distance from affiliationSmall // // //problem is here, affiliation.get Index: 2, Size: 2 // // matchValues.add(fuzzyMatch(affiliationSmall,affiliation.get(count))); // hixValues.add(tmpHix); // idValues.add(id); // } }//end of while rs1 -> faculty rs1.close(); int idx = 0; if(count>1) { moreFlag = true; //Call fuzzy match function, store the distance values and select the //affiliation that has the minimum distance from affiliationSmall //problem is here, affiliation.get Index: 2, Size: 2 matchValues.add(fuzzyMatch(affiliationSmall,affiliation.get(idx))); hixValues.add(tmpHix); idValues.add(id); idx++; } if(moreFlag) { Object obj = Collections.max(matchValues); float maxVal = Float.parseFloat(obj.toString()); //int tmpIdx = matchValues.indexOf(new Float(maxVal)); //get the index at which similarity between affiliation strings is maximum, //as returned by fuzzyMatch //int tmpIdx = matchValues.indexOf(maxVal); tmpIdx = matchValues.indexOf(maxVal); //get the hix at that index where the similarity is maximum //int tmpHidx = hixValues.get(tmpIdx); tmpHidx = hixValues.get(tmpIdx); tmpidIdx = idValues.get(tmpIdx); //update the smalldb table String updateQ = "UPDATE libra.smalldb SET hIx = ? WHERE name = ?"; //String updateQ = "UPDATE libra.smalldb SET hIx = ? WHERE current of "+cursorName; //PreparedStatement prepStmt1 = con.prepareStatement("UPDATE libra.smalldb SET hIx = ? WHERE current of "+cursorName); PreparedStatement prepStmt1 = con.prepareStatement(updateQ); //PreparedStatement prepStmt1 = con.prepareStatement(updateQ); prepStmt1.setString(2, name1); prepStmt1.setString(1, Integer.toString(tmpHidx)); prepStmt1.executeUpdate(updateQ); //prepStmt1.execute(); //stmt4.executeUpdate(updateQ); }//end of if //For matching names get the affiliation based on id from affiliation table //con.close(); //System.out.println(lastName); System.out.println(name); }//end of while rs -> smalldb rs.close(); // String updateQ = "UPDATE libra.smalldb1 SET hIx = "+Integer.toString(tmpHidx)+ "WHERE id = "+Integer.toString(tmpidIdx); // stmt4.executeUpdate(updateQ); con.close(); } catch (Exception e) { System.err.println("Got an exception! "); System.err.println(e.getMessage()); e.printStackTrace(); } } public static float fuzzyMatch(String affiliationSmall, String affiliation) { //float distance = 0; String[] temp = null; temp = affiliationSmall.split(" "); int index; //int index1 = affiliation.indexOf(affiliationSmall); int matchCount = 0; for (int idx = 0;idx<temp.length; idx++) { index = affiliation.indexOf(temp[idx]); if (index!=-1) { matchCount++; } } float tmpFloat = matchCount/temp.length; //int[] aff1= new int[affiliation1.length()]; //int[] aff2 = new int[affiliation2.length()]; return tmpFloat; } } i think it is because of the second select statement (rs0) Here is the error- Got an exception! You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '?' at line 1 com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '?' at line 1 at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) at java.lang.reflect.Constructor.newInstance(Unknown Source) at com.mysql.jdbc.Util.handleNewInstance(Util.java:409) at com.mysql.jdbc.Util.getInstance(Util.java:384) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1054) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3562) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3494) at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1960) at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2114) at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2690) at com.mysql.jdbc.StatementImpl.executeUpdate(StatementImpl.java:1648) at com.mysql.jdbc.StatementImpl.executeUpdate(StatementImpl.java:1567) at Jdbcexample1.main(Jdbcexample1.java:184)

    Read the article

  • The EXECUTE permission was denied on the object 'bam_Metadata_GetConfigurationXml'

    - by Andy Morrison
    We were seeing this exception on two servers when we tried to access the BAM Portal... after having to reconfigure the BAM Portal and Tools for reasons unrelated to the error: --- Log Name:      Application Source:        Bam Web Service Date:          2/18/2011 10:24:07 AM Event ID:      1534 Task Category: None Level:         Error Keywords:      Classic User:          N/A Computer:      yyyyyyyyyyyyyyyyyyyy Description: Current User: yy\yyyyyyyy EXCEPTION: Microsoft.BizTalk.Bam.Management.BamManagerException: Encountered error while executing command on SQL Server "yyyyyyyyyyyyyyy". ---> System.Data.SqlClient.SqlException: The EXECUTE permission was denied on the object 'bam_Metadata_GetConfigurationXml', database 'BAMPrimaryImport', schema 'dbo'.    at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)    at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)    at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)    at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)    at System.Data.SqlClient.SqlDataReader.ConsumeMetaData()    at System.Data.SqlClient.SqlDataReader.get_MetaData()    at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)    at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)    at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)    at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)    at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)    at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior)    at Microsoft.BizTalk.Bam.Management.SqlHelper.ExecuteQuery(String cmdText, CommandType cmdType, Transaction transaction)    --- End of inner exception stack trace ---    at Microsoft.BizTalk.Bam.Management.SqlHelper.ExecuteQuery(String cmdText, CommandType cmdType, Transaction transaction)    at Microsoft.BizTalk.Bam.Management.BamConfigurationManager.GetConfigurationXmlFromPrimaryImportDb()    at Microsoft.BizTalk.Bam.Management.BamConfigurationManager..ctor(String piServer, String piDatabase, Int32 sqlHelperCmdTimeout, Boolean validateServerNames)    at Microsoft.BizTalk.Bam.Management.BamManager..ctor(String primaryImportServer, String primaryImportDatabase, Int32 sqlCmdTimeout, Boolean validateServerNames)    at Microsoft.BizTalk.Bam.Management.BamManager..ctor(String primaryImportServer, String primaryImportDatabase)    at Microsoft.BizTalk.Bam.WebServices.Utilities.FetchBamManager()    at Microsoft.BizTalk.Bam.WebServices.Management.BamManagementService.GetViewSummaryForCurrentUser() EXCEPTION: Microsoft.BizTalk.Bam.Management.BamManagerException: Encountered error while executing command on SQL Server "yyyyyyyyyyyyyyyyyy". ---&gt; System.Data.SqlClient.SqlException: The EXECUTE permission was denied on the object 'bam_Metadata_GetConfigurationXml', database 'BAMPrimaryImport', schema 'dbo'.    at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)    at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)    at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)    at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)    at System.Data.SqlClient.SqlDataReader.ConsumeMetaData()    at System.Data.SqlClient.SqlDataReader.get_MetaData()    at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)    at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)    at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)    at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)    at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)    at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior)    at Microsoft.BizTalk.Bam.Management.SqlHelper.ExecuteQuery(String cmdText, CommandType cmdType, Transaction transaction)    --- End of inner exception stack trace ---    at Microsoft.BizTalk.Bam.Management.SqlHelper.ExecuteQuery(String cmdText, CommandType cmdType, Transaction transaction)    at Microsoft.BizTalk.Bam.Management.BamConfigurationManager.GetConfigurationXmlFromPrimaryImportDb()    at Microsoft.BizTalk.Bam.Management.BamConfigurationManager..ctor(String piServer, String piDatabase, Int32 sqlHelperCmdTimeout, Boolean validateServerNames)    at Microsoft.BizTalk.Bam.Management.BamManager..ctor(String primaryImportServer, String primaryImportDatabase, Int32 sqlCmdTimeout, Boolean validateServerNames)    at Microsoft.BizTalk.Bam.Management.BamManager..ctor(String primaryImportServer, String primaryImportDatabase)    at Microsoft.BizTalk.Bam.WebServices.Utilities.FetchBamManager()    at Microsoft.BizTalk.Bam.WebServices.Management.BamManagementService.GetViewSummaryForCurrentUser() --- We reconfigured the BAM Portal and Tools multiple times, trying to fix this issue, but kept getting the exception.  The fix was to add the BizTalk Server Administrators and BizTalk Application Users to the BAM_ManagementWS role in the BAMPrimaryImport database.  (Note that these two groups do not appear to be added to this role in a "clean" configuration. Thanks go to Ed at http://talentedmonkeys.wordpress.com/ for figuring out a solution.

    Read the article

  • Cannot create list in SharePoint 2010 using Client Object Model

    - by Boris
    I am trying to utilize SharePoint 2010 Client Object Model to create a List based on a custom template. Here's my code: public void MakeList(string title, string listTemplateGUID, int localeIdentifier) { string message; string listUrl; List newList; Guid template; ListCreationInformation listInfo; Microsoft.SharePoint.Client.ListCollection lists; try { listUrl = title.Replace(spaceChar, string.Empty); template = GetListTemplate((uint)localeIdentifier, listTemplateGUID); listInfo = new ListCreationInformation(); listInfo.Url = listUrl; listInfo.Title = title; listInfo.Description = string.Empty; listInfo.TemplateFeatureId = template; listInfo.QuickLaunchOption = QuickLaunchOptions.On; clientContext.Load(site); clientContext.ExecuteQuery(); lists = site.Lists; clientContext.Load(lists); clientContext.ExecuteQuery(); newList = lists.Add(listInfo); clientContext.ExecuteQuery(); } catch (ServerException ex) { //... } } Now, this particular part, newList = lists.Add(listInfo); clientContext.ExecuteQuery(); the one that is supposed to create the actual list, throws an exception: Message: Cannot complete this action. Please try again. ServerErrorCode: 2130239231 ServerErrorTypeName: Microsoft.SharePoint.SPException Could anyone please help me realize what am I doing wrong? Thanks.

    Read the article

  • JQuery and WCF - GET Method passes null

    - by user70192
    Hello, I have a WCF service that accepts requests from JQuery. Currently, I can access this service. However, the parameter value is always null. Here is my WCF Service definition: [OperationContract] [WebInvoke(Method = "GET", BodyStyle = WebMessageBodyStyle.WrappedRequest, RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)] public string ExecuteQuery(string query) { // NOTE: I get here, but the query parameter is always null string results = Engine.ExecuteQuery(query); return results; } Here is my JQuery call: var searchUrl = "/services/myService.svc/ExecuteQuery"; var json = { "query": eval("\"test query\"") }; alert(json2string(json)); // Everything is correct here if (json != null) { $.ajax({ type: "GET", url: searchUrl, contentType: "application/json; charset=utf-8", data: json2string(json), dataType: "json" }); } What am I doing wrong? It seems odd that I can call the service but the parameter is always null. Thank you

    Read the article

  • inserting number into oracle sql - using jython

    - by kdev
    I have this insert command where iam trying to insert a number to be taken from loop i=0 for line in column: myStmt.executeQuery("INSERT INTO REVERSE_COL ( TABLE_NAME,COL_NAME,POS) values (,'test','"+column[i]+"','"+i+"'") i=i+1 POS IS NUMBER DATATYPE but it works if i hard code as 1 i=0 for line in column: myStmt.executeQuery("INSERT INTO REVERSE_COL ( TABLE_NAME,COL_NAME,POS) values (,'test','"+column[i]+"',1") I have tried only i , +i+ and other method but its not working any suggestion how to solve this . Thanks everyone .

    Read the article

  • Android database closed exception

    - by Bombastic
    I'm working on a project where I'm downloading and saving data from web to sqlite database. A few minutes ago I receive a strange exception to our server from a user which is saying that the sqlite database is already closed..and I just checked the whole file where the exception happened and I'm not calling dbHelper.close();. Here is the function where the app crashes and LogCat message : public void insertCollectionCountries(JSONObject obj, Context context) { //Insert in collection_countries if(RPCCommunicator.isServiceRunning){ Log.w("","JsonCollection - insertCollectionCountries"); ContentValues valuesCountries = new ContentValues(); try { collectionId = Integer.parseInt(obj.getString("collection_id")); dbHelper.deleteSQL("collection_countries", "collection_id=?", new String[] {Integer.toString(collectionId)}); JSONArray arrayCountries = obj.getJSONArray("country_availability"); for (int i=0; i<arrayCountries.length(); i++) { valuesCountries.put("collection_id", collectionId); String countryCode = arrayCountries.getString(i); valuesCountries.put("country_code", countryCode); dbHelper.executeQuery("collection_countries", valuesCountries); } } catch (JSONException e){ e.printStackTrace(); } } } and the error is on that line : dbHelper.executeQuery("collection_countries", valuesCountries); here is the LogCat message : java.lang.IllegalStateException: database /data/data/com.stampii.stampii/databases/stampii_sys_tpl.sqlite (conn# 0) already closed at android.database.sqlite.SQLiteDatabase.verifyDbIsOpen(SQLiteDatabase.java:2123) at android.database.sqlite.SQLiteDatabase.setTransactionSuccessful(SQLiteDatabase.java:734) at com.stampii.stampii.comm.rpc.SystemDatabaseHelper.execQuery(SystemDatabaseHelper.java:298) at com.stampii.stampii.comm.rpc.SystemDatabaseHelper.executeQuery(SystemDatabaseHelper.java:291) at com.stampii.stampii.jsonAPI.JsonCollection.insertCollectionCounries(JsonCollection.java:548) at com.stampii.stampii.jsonAPI.JsonCollection.executeInsert(JsonCollection.java:181) at com.stampii.stampii.collections.MyService.downloadCollections(MyService.java:122) at com.stampii.stampii.collections.MyService$2.run(MyService.java:74) at java.lang.Thread.run(Thread.java:1020) and function in my dbHelperClass which I'm using to insert data : public boolean executeQuery(String tableName,ContentValues values){ return execQuery(tableName,values); } private boolean execQuery(String tableName,ContentValues values){ sqliteDb = instance.getWritableDatabase(); sqliteDb.beginTransaction(); sqliteDb.insert(tableName, null, values); sqliteDb.setTransactionSuccessful(); sqliteDb.endTransaction(); return true; } Any ideas which can close my sqlite database or what can cause that exception, because I've tested this code on a few emulators with different Android versions, different devices (HTC EVO 3D, Samsung Galaxy Nexus,HTC Desire, LG OPTIMUS PAD, Samsung Galaxy S2, Samsung Galaxy Note) and it's working fine. Thanks in advance!

    Read the article

  • Quering computed fields in GORM

    - by Tihom
    I am trying to query the following HQL using GORM: MailMessage.executeQuery("toId, count(toId) from (SELECT toId, threadId FROM MailMessage as m WHERE receiveStatus = '$u' GROUP BY threadId, toId) as x group by x.toId") The problem is that count(toId) is a computed field doesn't exist in MailMessage and that I am using a subquery. I get the following error: java.lang.IllegalArgumentException: node to traverse cannot be null! Ideally, I would like to use a generic executeQuery which will return data of anytype. Is there such a thing?

    Read the article

  • SharePoint 2010 - Client Object Model - Add attachment to ListItem

    - by Thorben
    Hi, I have a SharePoint List to which I'm adding new ListItems using the Client Object Model. Adding ListItems is not a problem and works great. Now I want to add attachments. I'm using the SaveBinaryDirect in the following manner: File.SaveBinaryDirect(clientCtx, url.AbsolutePath + "/Attachments/31/" + fileName, inputStream, true); It works without any problem as long as the item that I'm trying to add the attachment to, already has an attachment that was added through the SharePoint site and not using the Client Object Model. When I try to add an attachment to a item that doesnt have any attachments yet, I get the following errors (both happen but not with the same files - but those two messages appear consistently): The remote server returned an error: (409) Conflict The remote server returned an error: (404) Not Found I figured that maybe I need to create the attachment folder first for this item. When I try the following code: clientCtx.Load(ticketList.RootFolder.Folders); clientCtx.ExecuteQuery(); clientCtx.Load(ticketList.RootFolder.Folders[1]); // 1 -> Attachment folder clientCtx.Load(ticketList.RootFolder.Folders[1].Folders); clientCtx.ExecuteQuery(); Folder folder = ticketList.RootFolder.Folders[1].Folders.Add("33"); clientCtx.ExecuteQuery(); I receive an error message saying: Cannot create folder "Lists/Ticket System/Attachment/33" I have full administrator rights for the SharePoint site/list. Any ideas what I could be doing wrong? Thanks, Thorben

    Read the article

  • looping problem while appending data to existing text file

    - by Manu
    try { stmt = conn.createStatement(); stmt1 = conn.createStatement(); stmt2 = conn.createStatement(); rs = stmt.executeQuery("select cust from trip1"); rs1 = stmt1.executeQuery("select cust from trip2"); rs2 = stmt2.executeQuery("select cust from trip3"); File f = new File(strFileGenLoc); OutputStream os = (OutputStream)new FileOutputStream(f,true); String encoding = "UTF8"; OutputStreamWriter osw = new OutputStreamWriter(os, encoding); BufferedWriter bw = new BufferedWriter(osw); } while ( rs.next() ) { while(rs1.next()){ while(rs2.next()){ bw.write(rs.getString(1)==null? "":rs.getString(1)); bw.write("\t"); bw.write(rs1.getString(1)==null? "":rs1.getString(1)); bw.write("\t"); bw.write(rs2.getString(1)==null? "":rs2.getString(1)); bw.write("\t"); bw.newLine(); } } } Above code working fine. My problem is 1. "rs" resultset contains one record in the table 2. "rs1" resultset contains 5 record in the table 3. "rs2" resultset contains 5 record in the table "rs" data is getting recursive. while writing to the same text file , the output i am getting like 1 2 3 1 12 21 1 23 25 1 10 5 1 8 54 but i need output like below 1 2 3 12 21 23 25 10 5 8 54 What things i need to change in my code.. Please advice

    Read the article

  • iPhone and iPad : Doing a "select * from something" query in a SQLite database

    - by Abramodj
    Hi folks, i'm trying to use the SQLite data base in my iPad app, and here's my function to make a query: - (void)executeQuery:(char*)query { NSString *file = [self getWritableDBPath]; NSFileManager *fileManager = [NSFileManager defaultManager]; BOOL success = [fileManager fileExistsAtPath:file]; // If its not a local copy set it to the bundle copy if(!success) { //file = [[NSBundle mainBundle] pathForResource:DATABASE_TITLE ofType:@"db"]; [self createEditableCopyOfDatabaseIfNeeded]; } dataArray = NULL; dataArray = [NSMutableArray array]; sqlite3 *database = NULL; if (sqlite3_open([file UTF8String], &database) == SQLITE_OK) { sqlite3_exec(database, query, loadTimesCallback, dataArray, NULL); } sqlite3_close(database); [self logResults]; } if I call [self executeQuery:"select name from table1"]; everything is working fine. But if i call [self executeQuery:"select * from cars"]; the app crashes telling me that the NSMutableArray dataArray is not the right kind of variable where to set the query results. So, how can i do a "select * form table1" query, and store the results? Thanks! EDIT: Here's my loadTimesCallback method: static int loadTimesCallback(void *context, int count, char **values, char **columns) { NSMutableArray *times = (NSMutableArray *)context; for (int i=0; i < count; i++) { const char *nameCString = values[i]; [times addObject:[NSString stringWithUTF8String:nameCString]]; } return SQLITE_OK; }

    Read the article

  • Java program will read from database, but not write to it

    - by ck1221
    I have a Java program that successfully connects to a mysql database that is hosted on godaddy's server. I can read from that db with out issue, however, when I try to write to it with INSERT or UPDATE for example, the query does not execute. I am using the 'admin' account that I set up through godaddy, I realize this is not the root account. I have checked and verified that the connection is not read only, and have logged out of phpmyadmin while the query ran. I'm not sure what else I can try or if anyone has experienced this issue. Maybe a setting to the connection I have failed to set? Or maybe its not possible since the db is hosted on godaddy's servers? Any help is great! Thanks. Here is some relevant code: Connection to db: Connection con; public DBconnection(String url, String user, String pass) { try { Class.forName("com.mysql.jdbc.Driver").newInstance(); con = DriverManager.getConnection (url,user,pass); if(!con.isClosed()) System.out.println("connecton open"); } catch (InstantiationException e) {e.printStackTrace();} catch (IllegalAccessException e) {e.printStackTrace();} catch (ClassNotFoundException e) {e.printStackTrace();} catch (SQLException e) {e.printStackTrace();} } Send Query: public ResultSet executeQuery(String query) { ResultSet rs = null; try { Statement stmt = (Statement) con.createStatement(); rs = stmt.executeQuery(query); //while(rs.next()) //System.out.println(rs.getString("ticket_num")); } catch (SQLException e) {} return rs; } Insert Query (works in phpmyadmin): conn.executeQuery("INSERT INTO tickets VALUES(55555,'12/01/2012','me','reports','test','','','0','Nope')");

    Read the article

  • PreparedStatement

    - by Steel Plume
    Hello, in the case of using PreparedStatement with a single common connection without any pool, can I recreate an instance for every dml/sql operation mantaining the power of prepared statements? I mean: for (int i=0; i<1000; i++) { PreparedStatement preparedStatement = connection.prepareStatement(sql); preparedStatement.setObject(1, someValue); preparedStatement.executeQuery(); preparedStatement.close(); } instead of: PreparedStatement preparedStatement = connection.prepareStatement(sql); for (int i=0; i<1000; i++) { preparedStatement.clearParameters(); preparedStatement.setObject(1, someValue); preparedStatement.executeQuery(); } preparedStatement.close(); my question arises by the fact that I want to put this code into a multithreaded environment, can you give me some advice? thanks

    Read the article

  • Reusing a PreparedStatement multiple times

    - by Steel Plume
    Hello, in the case of using PreparedStatement with a single common connection without any pool, can I recreate an instance for every dml/sql operation mantaining the power of prepared statements? I mean: for (int i=0; i<1000; i++) { PreparedStatement preparedStatement = connection.prepareStatement(sql); preparedStatement.setObject(1, someValue); preparedStatement.executeQuery(); preparedStatement.close(); } instead of: PreparedStatement preparedStatement = connection.prepareStatement(sql); for (int i=0; i<1000; i++) { preparedStatement.clearParameters(); preparedStatement.setObject(1, someValue); preparedStatement.executeQuery(); } preparedStatement.close(); my question arises by the fact that I want to put this code into a multithreaded environment, can you give me some advice? thanks

    Read the article

  • How can I transfer output that appears on the console and format it so that it appears on a web page

    - by lojayna
    package collabsoft.backlog_reports.c4; import java.sql.CallableStatement; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.ResultSetMetaData; import java.sql.Statement; //import collabsoft.backlog_reports.c4.Report; public class Report { private Connection con; public Report(){ connectUsingJDBC(); } public static void main(String args[]){ Report dc = new Report(); dc.reviewMeeting(6, 8, 10); dc.createReport("dede",100); //dc.viewReport(100); // dc.custRent(3344,123,22,11-11-2009); } /** the following method is used to connect to the database **/ public void connectUsingJDBC() { // This is the name of the ODBC data source String dataSourceName = "Simple_DB"; try { // loading the driver in the memory Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); // This is the connection URL String dbURL = "jdbc:odbc:" + dataSourceName; con = DriverManager.getConnection("jdbc:mysql://localhost:3306/Collabsoft","root",""); // This line is used to print the name of the driver and it would throw an exception if a problem occured System.out.println("User connected using driver: " + con.getMetaData().getDriverName()); //Addcustomer(con,1111,"aaa","aaa","aa","aam","111","2222","111"); //rentedMovies(con); //executePreparedStatement(con); //executeCallableStatement(con); //executeBatch(con); } catch (Exception e) { e.printStackTrace(); } } /** *this code is to link the SQL code with the java for the task *as an admin I should be able to create a report of a review meeting including notes, tasks and users *i will take the task id and user id and note id that will be needed to be added in the review *meeting report and i will display the information related to these ida **/ public void reviewMeeting(int taskID, int userID, int noteID)// law el proc bt return table { try{ CallableStatement callableStatement = con.prepareCall("{CALL report_review_meeting(?,?,?)}"); callableStatement.setInt(1,taskID); callableStatement.setInt(2,userID); callableStatement.setInt(3,noteID); ResultSet resultSet = callableStatement.executeQuery(); // or executeupdate() or updateQuery ResultSetMetaData rsm = resultSet.getMetaData(); int numOfColumns = rsm.getColumnCount(); System.out.println("lojayna"); while (resultSet.next()) { System.out.println("New Row:"); for (int i = 1; i <= numOfColumns; i++) System.out.print(rsm.getColumnName(i) + ": " + resultSet.getObject(i) + " "); System.out.println(); } } catch(Exception e) { System.out.println("E"); } } ////////////////////////////////// ///////////////////////////////// public void allproject(int projID)// law el proc bt return table { try{ CallableStatement callableStatement = con.prepareCall("{CALL all_project(?)}"); callableStatement.setInt(1,projID); //callableStatement.setInt(2,userID); //callableStatement.setInt(3,noteID); ResultSet resultSet = callableStatement.executeQuery(); // or executeupdate() or updateQuery ResultSetMetaData rsm = resultSet.getMetaData(); int numOfColumns = rsm.getColumnCount(); System.out.println("lojayna"); while (resultSet.next()) { System.out.println("New Row:"); for (int i = 1; i <= numOfColumns; i++) System.out.print(rsm.getColumnName(i) + ": " + resultSet.getObject(i) + " "); System.out.println(); } } catch(Exception e) { System.out.println("E"); } } /////////////////////////////// /** * here i take the event id and i take a string report and then * i relate the report with the event **/ public void createReport(String report,int E_ID )// law el proc bt return table { try{ Statement st = con.createStatement(); st.executeUpdate("UPDATE e_vent SET e_vent.report=report WHERE e_vent.E_ID= E_ID;"); /* CallableStatement callableStatement = con.prepareCall("{CALL Create_report(?,?)}"); callableStatement.setString(1,report); callableStatement.setInt(2,E_ID); ResultSet resultSet = callableStatement.executeQuery(); // or executeupdate() or updateQuery ResultSetMetaData rsm = resultSet.getMetaData(); int numOfColumns = rsm.getColumnCount(); System.out.println("lojayna"); while (resultSet.next()) { System.out.println("New Row:"); for (int i = 1; i <= numOfColumns; i++) System.out.print(rsm.getColumnName(i) + ": " + resultSet.getObject(i) + " "); System.out.println(); }*/ } catch(Exception e) { System.out.println("E"); System.out.println(e); } } /** *in the following method i view the report of the event having the ID eventID **/ public void viewReport(int eventID)// law el proc bt return table { try{ CallableStatement callableStatement = con.prepareCall("{CALL view_report(?)}"); callableStatement.setInt(1,eventID); ResultSet resultSet = callableStatement.executeQuery(); // or executeupdate() or updateQuery ResultSetMetaData rsm = resultSet.getMetaData(); int numOfColumns = rsm.getColumnCount(); System.out.println("lojayna"); while (resultSet.next()) { System.out.println("New Row:"); for (int i = 1; i <= numOfColumns; i++) System.out.print(rsm.getColumnName(i) + ": " + resultSet.getObject(i) + " "); System.out.println(); } } catch(Exception e) { System.out.println("E"); } } } // the result of these methods is being showed on the console , i am using WIcket and i want it 2 be showed on the web how is that done ?!

    Read the article

  • i want to show the result of my code on a web page because it is being showed on a console??

    - by lojayna
    package collabsoft.backlog_reports.c4; import java.sql.CallableStatement; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.ResultSetMetaData; import java.sql.Statement; //import collabsoft.backlog_reports.c4.Report; public class Report { private Connection con; public Report(){ connectUsingJDBC(); } public static void main(String args[]){ Report dc = new Report(); dc.reviewMeeting(6, 8, 10); dc.createReport("dede",100); //dc.viewReport(100); // dc.custRent(3344,123,22,11-11-2009); } /** the following method is used to connect to the database **/ public void connectUsingJDBC() { // This is the name of the ODBC data source String dataSourceName = "Simple_DB"; try { // loading the driver in the memory Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); // This is the connection URL String dbURL = "jdbc:odbc:" + dataSourceName; con = DriverManager.getConnection("jdbc:mysql://localhost:3306/Collabsoft","root",""); // This line is used to print the name of the driver and it would throw an exception if a problem occured System.out.println("User connected using driver: " + con.getMetaData().getDriverName()); //Addcustomer(con,1111,"aaa","aaa","aa","aam","111","2222","111"); //rentedMovies(con); //executePreparedStatement(con); //executeCallableStatement(con); //executeBatch(con); } catch (Exception e) { e.printStackTrace(); } } /** *this code is to link the SQL code with the java for the task *as an admin I should be able to create a report of a review meeting including notes, tasks and users *i will take the task id and user id and note id that will be needed to be added in the review meeting report and i will display the information related to these ida */ public void reviewMeeting(int taskID, int userID, int noteID)// law el proc bt return table { try{ CallableStatement callableStatement = con.prepareCall("{CALL report_review_meeting(?,?,?)}"); callableStatement.setInt(1,taskID); callableStatement.setInt(2,userID); callableStatement.setInt(3,noteID); ResultSet resultSet = callableStatement.executeQuery(); // or executeupdate() or updateQuery ResultSetMetaData rsm = resultSet.getMetaData(); int numOfColumns = rsm.getColumnCount(); System.out.println("lojayna"); while (resultSet.next()) { System.out.println("New Row:"); for (int i = 1; i <= numOfColumns; i++) System.out.print(rsm.getColumnName(i) + ": " + resultSet.getObject(i) + " "); System.out.println(); } } catch(Exception e) { System.out.println("E"); } } ////////////////////////////////// ///////////////////////////////// public void allproject(int projID)// law el proc bt return table { try{ CallableStatement callableStatement = con.prepareCall("{CALL all_project(?)}"); callableStatement.setInt(1,projID); //callableStatement.setInt(2,userID); //callableStatement.setInt(3,noteID); ResultSet resultSet = callableStatement.executeQuery(); // or executeupdate() or updateQuery ResultSetMetaData rsm = resultSet.getMetaData(); int numOfColumns = rsm.getColumnCount(); System.out.println("lojayna"); while (resultSet.next()) { System.out.println("New Row:"); for (int i = 1; i <= numOfColumns; i++) System.out.print(rsm.getColumnName(i) + ": " + resultSet.getObject(i) + " "); System.out.println(); } } catch(Exception e) { System.out.println("E"); } } /////////////////////////////// /** * here i take the event id and i take a string report and then * i relate the report with the event **/ public void createReport(String report,int E_ID )// law el proc bt return table { try{ Statement st = con.createStatement(); st.executeUpdate("UPDATE e_vent SET e_vent.report=report WHERE e_vent.E_ID= E_ID;"); /* CallableStatement callableStatement = con.prepareCall("{CALL Create_report(?,?)}"); callableStatement.setString(1,report); callableStatement.setInt(2,E_ID); ResultSet resultSet = callableStatement.executeQuery(); // or executeupdate() or updateQuery ResultSetMetaData rsm = resultSet.getMetaData(); int numOfColumns = rsm.getColumnCount(); System.out.println("lojayna"); while (resultSet.next()) { System.out.println("New Row:"); for (int i = 1; i <= numOfColumns; i++) System.out.print(rsm.getColumnName(i) + ": " + resultSet.getObject(i) + " "); System.out.println(); }*/ } catch(Exception e) { System.out.println("E"); System.out.println(e); } } /** in the following method i view the report of the event having the ID eventID */ public void viewReport(int eventID)// law el proc bt return table { try{ CallableStatement callableStatement = con.prepareCall("{CALL view_report(?)}"); callableStatement.setInt(1,eventID); ResultSet resultSet = callableStatement.executeQuery(); // or executeupdate() or updateQuery ResultSetMetaData rsm = resultSet.getMetaData(); int numOfColumns = rsm.getColumnCount(); System.out.println("lojayna"); while (resultSet.next()) { System.out.println("New Row:"); for (int i = 1; i <= numOfColumns; i++) System.out.print(rsm.getColumnName(i) + ": " + resultSet.getObject(i) + " "); System.out.println(); } } catch(Exception e) { System.out.println("E"); } } } // the result of these methods is being showed on the console , i am using WIcket and i want it 2 be showed on the web how is that done ?! thnxxx

    Read the article

  • Unable to execute stored Procedure using Java and JDBC on SQL server

    - by jwmajors81
    I have been trying to execute a MS SQL Server stored procedure via JDBC today and have been unsuccessful thus far. The stored procedure has 1 input and 1 output parameter. With every combination I use when setting up the stored procedure call in code I get an error stating that the stored procedure couldn't be found. I have provided the stored procedure I'm executing below (NOTE: this is vendor code, so I cannot change it). set ANSI_NULLS ON set QUOTED_IDENTIFIER ON GO ALTER PROC [dbo].[spWCoTaskIdGen] @OutIdentifier int OUTPUT AS BEGIN DECLARE @HoldPolicyId int DECLARE @PolicyId char(14) IF NOT EXISTS ( SELECT * FROM UniqueIdentifierGen (UPDLOCK) ) INSERT INTO UniqueIdentifierGen VALUES (0) UPDATE UniqueIdentifierGen SET CurIdentifier = CurIdentifier + 1 SELECT @OutIdentifier = (SELECT CurIdentifier FROM UniqueIdentifierGen) END The code looks like: CallableStatement statement = connection .prepareCall("{call dbo.spWCoTaskIdGen(?)}"); statement.setInt(1, 0); ResultSet result = statement.executeQuery(); I get the following error: SEVERE: Could not find stored procedure 'dbo.spWCoTaskIdGen'. I have also tried CallableStatement statement = connection .prepareCall("{? = call dbo.spWCoTaskIdGen(?)}"); statement.registerOutParameter(1, java.sql.Types.INTEGER); statement.registerOutParameter(2, java.sql.Types.INTEGER); statement.executeQuery(); The above results in: SEVERE: Could not find stored procedure 'dbo.spWCoTaskIdGen'. I have also tried: CallableStatement statement = connection .prepareCall("{? = call spWCoTaskIdGen(?)}"); statement.registerOutParameter(1, java.sql.Types.INTEGER); statement.registerOutParameter(2, java.sql.Types.INTEGER); statement.executeQuery(); The code above resulted in the following error: Could not find stored procedure 'spWCoTaskIdGen'. Finally, I should also point out the following: I have used the MS SQL Server Management Studio tool and have been able to successfully run the stored procedure. The sql generated to execute the stored procedure is provided below: GO DECLARE @return_value int, @OutIdentifier int EXEC @return_value = [dbo].[spWCoTaskIdGen] @OutIdentifier = @OutIdentifier OUTPUT SELECT @OutIdentifier as N'@OutIdentifier ' SELECT 'Return Value' = @return_value GO The code being executed runs with the same user id that was used in point #1 above. In the code that creates the Connection object I log which database I'm connecting to and the code is connecting to the correct database. Any ideas? Thank you very much in advance.

    Read the article

  • Unable to execute stored Procedure using Java and JDBC

    - by jwmajors81
    I have been trying to execute a MS SQL Server stored procedure via JDBC today and have been unsuccessful thus far. The stored procedure has 1 input and 1 output parameter. With every combination I use when setting up the stored procedure call in code I get an error stating that the stored procedure couldn't be found. I have provided the stored procedure I'm executing below (NOTE: this is vendor code, so I cannot change it). set ANSI_NULLS ON set QUOTED_IDENTIFIER ON GO ALTER PROC [dbo].[spWCoTaskIdGen] @OutIdentifier int OUTPUT AS BEGIN DECLARE @HoldPolicyId int DECLARE @PolicyId char(14) IF NOT EXISTS ( SELECT * FROM UniqueIdentifierGen (UPDLOCK) ) INSERT INTO UniqueIdentifierGen VALUES (0) UPDATE UniqueIdentifierGen SET CurIdentifier = CurIdentifier + 1 SELECT @OutIdentifier = (SELECT CurIdentifier FROM UniqueIdentifierGen) END The code looks like: CallableStatement statement = connection .prepareCall("{call dbo.spWCoTaskIdGen(?)}"); statement.setInt(1, 0); ResultSet result = statement.executeQuery(); I get the following error: SEVERE: Could not find stored procedure 'dbo.spWCoTaskIdGen'. I have also tried CallableStatement statement = connection .prepareCall("{? = call dbo.spWCoTaskIdGen(?)}"); statement.registerOutParameter(1, java.sql.Types.INTEGER); statement.registerOutParameter(2, java.sql.Types.INTEGER); statement.executeQuery(); The above results in: SEVERE: Could not find stored procedure 'dbo.spWCoTaskIdGen'. I have also tried: CallableStatement statement = connection .prepareCall("{? = call spWCoTaskIdGen(?)}"); statement.registerOutParameter(1, java.sql.Types.INTEGER); statement.registerOutParameter(2, java.sql.Types.INTEGER); statement.executeQuery(); The code above resulted in the following error: Could not find stored procedure 'spWCoTaskIdGen'. Finally, I should also point out the following: I have used the MS SQL Server Management Studio tool and have been able to successfully run the stored procedure. The sql generated to execute the stored procedure is provided below: GO DECLARE @return_value int, @OutIdentifier int EXEC @return_value = [dbo].[spWCoTaskIdGen] @OutIdentifier = @OutIdentifier OUTPUT SELECT @OutIdentifier as N'@OutIdentifier ' SELECT 'Return Value' = @return_value GO The code being executed runs with the same user id that was used in point #1 above. In the code that creates the Connection object I log which database I'm connecting to and the code is connecting to the correct database. Any ideas? Thank you very much in advance.

    Read the article

1 2 3 4 5 6 7 8 9  | Next Page >