Is there a way to get a total counts from the resultset of two unions? This will be for DB2. select count(*) from ( select count(*) from xyz where abc='1' union all select count(*) from x1y1z1 where abc='1' )

Member Avatar
Member Avatar
+0 forum 2

How to pass an row from resultset to an array[some index]=$row;

Member Avatar
Member Avatar
+0 forum 2

Hey guys, i found this tutorial online that involved searching your database for an existing value. I have changed the code around so it fits with my system but when i run it the input displays but once i press ok the input box closes and nothin else happens. Heres the Code : private void checkButtonActionPerformed(java.awt.event.ActionEvent evt) { Scanner sc = new Scanner(System.in); try{ java.sql.Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/ireland","root" ,"password"); Statement stmt = con.createStatement(); JOptionPane.showInputDialog("Please Enter the pubs name you wish to search."); String pubName = sc.next(); String SQL = "SELECT * FROM pubs WHERE Pub_Name = '" + pubName +"'"; …

Member Avatar
Member Avatar
+0 forum 5

//compute percentage for Parent1 DecimalFormat df = new DecimalFormat("#.##%"); rs = s.executeQuery("SELECT " + "(SELECT COUNT(*) FROM genetic.blood_type where diseases = '" + disease1 + "')" + "/COUNT(*) AS rowcount FROM genetic.blood_type where btype = '" + btype1 + "'"); rs.next(); int result = rs.getInt("rowcount"); rs.close(); out.println(disease1 + " is " + df.format(result) +" "+ result);

Member Avatar
Member Avatar
+0 forum 2

For Security Concern, I am using mssql_execute(). I am not getting way to get the recordset return from procedure. Below is my sample code $query = mssql_init("USP_GET_ICIN_DATA",$mssql_link); mssql_bind($query, '@ICIN_NUMBERS',trim($icin_data), SQLVARCHAR, false); mssql_bind($query, '@FROMRECORDNUMBER', $start, SQLINT4, false); mssql_bind($query, '@LIMIT', $limit, SQLINT4, false); $result = mssql_execute($query); while ($row = mssql_fetch_assoc($result)) { $icin = $row["ICIN"]; $commodity = $row["CommodityName"]; echo $icin." " . $commodity; } Previously it was working find with mssql_query(). But for security Concern i am using mssql_execute().

Member Avatar
Member Avatar
+0 forum 2

i am facing a problem in running multiple queries in jsp page, as it is unable to store the values in the 2nd result set i use in my page. tha code is written below: [code] String strQuery = "select * from services "; ResultSet rs =null; ResultSet rs1 = null; rs = st.executeQuery(strQuery); while(rs.next()) { String[] serviceArray; serviceArray = request.getParameterValues("services"); for (int i = 0; i < serviceArray.length; i++) { //Retreive service Name to put in Prof_strig. String sql = "select * from services"; out.println(sql); rs1= st1.executeQuery(sql); while(rs1.next()) { <tr> <td><%=rs1.getString(1) %></td> <td> <%=rs1.getString(2) %></td> </tr> <% } } …

Member Avatar
Member Avatar
+0 forum 8

I am using getRow() method of ResultSet class like: int rowCount = result.getRow(); but when i run the application, it gives me the exception that says: *The 'getRow()' method is only allowed on scroll cursors.* Please, anyone, who knows why it happened, explain it with some possible solutions Thanks!

Member Avatar
Member Avatar
+0 forum 1

I am using two ResultSet in a single statement..this code is a part of servlet.. [CODE] String temp=request.getParameter("cid"); int cid= Integer.parseInt(temp); Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection con = DriverManager.getConnection("jdbc:odbc:Mydatasource"); PreparedStatement ps = con.prepareStatement("select * from Products where cid=?"); ps.setInt(1, cid); ResultSet rs = ps.executeQuery(); while(rs.next()) { out.println("<a href = 's_BikeServlet?pid="+ rs.getInt(1) + "'>" + "rs.getString(2)" + "</a>"); //rs.getString get the name of the bike which has to be made a hyperlink } [/CODE] but when i run this.it give java.sql.SQLEXCEPTION (No Data found)..but when i use only single ResultSet it Displays correctly..

Member Avatar
Member Avatar
+0 forum 26

Below is what I have been attempting to do. [code]retrive number of rows from MySql table; for(int i = 1; i <= numberOfRows; i++){ retrive userID, level at position(i) in table; // next i need to insert userID into array, level amount of times (ex. userID = 4, level = 6, insert [4,4,4,4,4,4] into array) while (j < level + numberOfItemsInArrayPrior){ hugeArray[j] = userID; j++; } numberOfItemsInArrayPrior += level; }[/code] I finally got it to print out without errors, but it is printing a ton of zeros between numbers when i print the array. [code]static int maxIndex; static int numberOfEntries; …

Member Avatar
Member Avatar
+0 forum 3

I am attempting to take 2 integers from a MySql table. X represents a number that will be stored into an array. Y represents the number of times that X will be put into the array. I am attempting to make a loop that will go through, find all the Xs, along with their corresponding Ys and store X into an array Y amount of times... This is an example of what I have been attempting... [CODE]try{ Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "root"); Statement st=con.createStatement(); // Selects the highest index of X so all Xs get stored into array ResultSet …

Member Avatar
Member Avatar
+0 forum 3

I use two ResultSet , One in the another one. [CODE] try { con1 = DriverManager.getConnection ("jdbc:odbc:java"); smt1=con.createStatement(); if(sele.equals("ALL")) { rs=smt.executeQuery("select * from Stations where State='"+st+"'"); } else { rs=smt.executeQuery("select * from Stations where City='"+sele+"'"); } while(rs.next()) { stid=rs.getString(1); ofid=rs.getString(2); name=rs.getString(3); num=rs.getString(4); des=rs.getString(5); dis=rs.getString(6); %> <tr style="border: blue dotted thick"> <td style="border: blue dotted thin" align="center" ><a style="color: red;" href="view.jsp?<%=stid%>" ><%=stid%></a></td> <td style="border: blue dotted thin" align="center"><%=ofid%></td> <td style="border: blue dotted thin" align="center"><%=dis%></td> <td style="border: blue dotted thin; " align="center"> <%=name%> </td> <td style="border: blue dotted thin" align="center"><%=num%></td> <td style="border: blue dotted thin" align="center"><%=des%></td> <% rs1=smt.executeQuery("Select Count(*) from Officer where …

Member Avatar
Member Avatar
+0 forum 7

Hi, I'm trying to present results on an aspx web page where a store procedure parameter is defined by a dropdown list control on the page. To help accomplish this, I have followed [URL="http://support.microsoft.com/kb/306574"]this guide from Microsoft[/URL] and have my resultset presented in a DataGrid view. But I cannot seem to adapt it to present the resultset in a chart. As you can see from my VB code below, I thought it would simply be a case of adapting the GridView databind to a Chart. I have tried various other options, and have successfully generated my data in a chart …

Member Avatar
Member Avatar
+0 forum 2

I have a somewhat complicated select query which returns, in part, the following resultset (as an example): [code=text] threadid views -------- ----- 1 5 1 5 2 10 3 15 4 10 [/code] If I were to do the following select: [code]COUNT (DISTINCT threadid), SUM (DISTINCT views)[/code] then it would return 4, 30. (5 + 10 + 15) I am looking for a select where I want to find the SUM of views for distinct threadids, not distinct views. Something that would return 4, 40. (5 + 10 + 15 + 10) Is there something I can do?

Member Avatar
Member Avatar
+0 forum 4

i have a jsp page with some fields ...i.e textfields n below that i have some 4 buttons named first,next,prev,last when i click on the button named 'first' i should get the first record from the database n if i click on the button named 'next' i should get the next record from the database n so on for the last n prev button. i should get the records onto the same page. i dont know how i am going to maintain the 'resultSet' data all throughout my program... can anyone tell me the way to go about it...

Member Avatar
Member Avatar
+0 forum 3

hi friends, I am a novice java programmer. I am in a learning process in java servlets. But i struck into a Class method which should return a result set([B]result of a join query[/B])as a an arrayList using the existing bean class. I will show my code as some one can point out what i should do or suggest me a (standard) method to access it. I am having a separate bean class for table users and table books. A book table which has list of books info, A user table which has list of users info, when a user …

Member Avatar
Member Avatar
+0 forum 2

I have this output from a mysql export: [code] <?xml version="1.0"?> <resultset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" statement="select product as sample,count(*) as count from table1 where itemno in (5,10,37) and type='food' and package='boxed' group by package,product order by count(*),product desc limit 5 "> <row> <sample>cereal</sample> <count>1</count> </row> <row> <sample>macaroni</sample> <count>1</count> </row> <row> <sample>cookies</sample> <count>2</count> </row> <row> <sample>rice</sample> <count>2</count> </row> <row> <sample>stuffing</sample> <count>7</count> </row> </resultset> [/code] I want to use xslt to replace <resultset xmlns:xsi=......> and </resultset> with another tag, like <groceries xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"></groceries>, but without the query statement included. Suggestions?

Member Avatar
Member Avatar
+0 forum 10

hi friends, I am a novice java programmer. I am in a learning process in java servlets. But i struck into a Class method which should return a result set as an array. I will show my code as some one can point out where am i going wrong. Currently im dealing with null value exception. Any one help me to get rid of that. Or suggest me a new (standard) method to access it. please treat me novice in java servlet My servlet file in doGet() [CODE] protected void showAllUsers(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { PrintWriter out …

Member Avatar
Member Avatar
+0 forum 6

I have a client and a server - the client sends the server a message, and depending on what message is sent, the server will perform an action and then reply to the client. Most of the actions that I have implemented are working. I need help with one of the actions though - The client will send the server a request. The server has to query a database and then return the results to the client. Is it possible to send a resultset from the server to the client? If so, what function will I use, and if not, …

Member Avatar
Member Avatar
+0 forum 3

Hi everyone, I want to convert [B]JDBC ResultSet to JSON Array[/B]. As u guess, direct casting isn't allowed.. How can I convert my DB data which is stored in ResultSet to a JSON Array? I'll be happy if someone can help me. Thanx in advance, With regards, Talha..

Member Avatar
+0 forum 0

The End.