jdbc

Java exception: the statement didn't return a resultset

被刻印的时光 ゝ 提交于 2021-02-05 09:45:22
问题 My original environment is SQL server 2005 + WebSphere v6.0(JDBC 3.0) . When I run the program as below and it works well. ResultSet rs=stmt.executeQuery(sql); rs.next(); However, when I upgrade the environment to SQL server 2005 + WebSphere v8.5(JDBC 4.0) , I get the error message: com.microsoft.sqlserver.jdbc.SQLServerException: The statement did not return a result set. From this forum's information, it seems that I have multiple resultsets, so I try to change the program as follows and it

Oracle RESET_PACKAGE does not reset value of a variable in the session

邮差的信 提交于 2021-02-05 09:42:42
问题 I have an app where JDBC connections are pooled. This is related to my question. For simplicity let's assume I have 1 connection and I need to set a variable then reset session / context state. However the idea is not reverse / reset the 'app1_ctx' variable particularly as in the actual case users can enter many procedures that set many variables so what I need is one procedure that clears all session related variables or even restart session. (please check this question too to understand the

JAVA JDBC mySql Prepared statement Update query [duplicate]

柔情痞子 提交于 2021-02-05 07:45:27
问题 This question already has answers here : MySQLSyntaxErrorException near “?” when trying to execute PreparedStatement (2 answers) Closed 1 year ago . I am trying to execute the following code package jdbclesson; import java.sql.*; public class PreparedQuery { public static void main(String[] args) throws Exception { String url = "jdbc:mysql://localhost:3306/alien?useSSL=false"; String uname = "root"; String pass = "ma123"; String query = "UPDATE student SET username= ? where userid= ? ";

Error with PreparedStatement

穿精又带淫゛_ 提交于 2021-02-05 07:45:06
问题 So I have a method which returns the items names that I get. But with the first query it returns an error. Which to my opinion shouldn't be there because its the right syntax. Here is the code: void showInventory(String userId, MessageReceivedEvent event) throws HTTP429Exception, DiscordException, MissingPermissionsException{ sendMessage("test0",event); String sql = "SELECT itemID FROM inventory WHERE playerID=?"; String sql2 = "SELECT Name FROM items WHERE ID=?"; java.sql.PreparedStatement

JAVA JDBC mySql Prepared statement Update query [duplicate]

杀马特。学长 韩版系。学妹 提交于 2021-02-05 07:45:06
问题 This question already has answers here : MySQLSyntaxErrorException near “?” when trying to execute PreparedStatement (2 answers) Closed 1 year ago . I am trying to execute the following code package jdbclesson; import java.sql.*; public class PreparedQuery { public static void main(String[] args) throws Exception { String url = "jdbc:mysql://localhost:3306/alien?useSSL=false"; String uname = "root"; String pass = "ma123"; String query = "UPDATE student SET username= ? where userid= ? ";

“x is a procedure, use ”call“” when I am already using call

拈花ヽ惹草 提交于 2021-02-05 07:09:49
问题 I'm using Postgres 12 and have written this procedure: CREATE OR REPLACE PROCEDURE reduceStock(id INTEGER, soldQuantity INTEGER) LANGUAGE plpgsql AS $$ BEGIN UPDATE inventory SET ProductStockAmount = ProductStockAmount - soldQuantity WHERE ProductID = id; END; $$; It works perfectly if I open up psql on the command line and run call reduceStock(1,1); However, calling it from my Java program as follows: CallableStatement stmt = conn.prepareCall("{call reduceStock(?, ?)}"); stmt.setInt(1,

“x is a procedure, use ”call“” when I am already using call

空扰寡人 提交于 2021-02-05 07:09:34
问题 I'm using Postgres 12 and have written this procedure: CREATE OR REPLACE PROCEDURE reduceStock(id INTEGER, soldQuantity INTEGER) LANGUAGE plpgsql AS $$ BEGIN UPDATE inventory SET ProductStockAmount = ProductStockAmount - soldQuantity WHERE ProductID = id; END; $$; It works perfectly if I open up psql on the command line and run call reduceStock(1,1); However, calling it from my Java program as follows: CallableStatement stmt = conn.prepareCall("{call reduceStock(?, ?)}"); stmt.setInt(1,

“x is a procedure, use ”call“” when I am already using call

廉价感情. 提交于 2021-02-05 07:09:23
问题 I'm using Postgres 12 and have written this procedure: CREATE OR REPLACE PROCEDURE reduceStock(id INTEGER, soldQuantity INTEGER) LANGUAGE plpgsql AS $$ BEGIN UPDATE inventory SET ProductStockAmount = ProductStockAmount - soldQuantity WHERE ProductID = id; END; $$; It works perfectly if I open up psql on the command line and run call reduceStock(1,1); However, calling it from my Java program as follows: CallableStatement stmt = conn.prepareCall("{call reduceStock(?, ?)}"); stmt.setInt(1,

How to insert the dynamic added row values into the database using JDBC Servlets

夙愿已清 提交于 2021-02-04 21:40:37
问题 Here is my jsp code, am adding and deleting the rows dynamically using javascript,but while inserting the details into the database mysql,it will insert only 1 row..How to add the dynamically added row values into the database using servlets.. Here is my code <html> <head> <title> Timeline Sheet</title> <SCRIPT language="javascript"> $('form').change(function(){ $('form').submit(); }); function validLogin(){ if (document.form.eid.value == ""){ alert ( "Please enter Employee Id." ); document

Show users with any privileges to database. MySQL

匆匆过客 提交于 2021-02-04 09:39:26
问题 i have to select all users with any privileges to database (e.g. database 'mysql'). Any suggestions? Thanks. 回答1: Look the in mysql database (an actual db named mysql inside the mysql server, just to be clear). There's three tables ( db , tables_priv , and columns_priv ) where the db/table/column privs are stored: SELECT 'db', User, Host FROM db WHERE Db='mydatabase' UNION SELECT 'table', User, Host FROM tables_priv WHERE Db='mydatabase' UNION SELECT 'col', User, Host FROM columns_priv WHERE