Combinatorial Queries - Changing Parameters Actual Values
Apr 30, 2014
I have a question about query execution strategy ...
Scenario: let's suppose I've to query a table with a query like
SELECT F1, F2, F3 FROM MYTABLE WHERE F1 = ? AND F2 = ? AND F3 = ?.
I need to execute this query changing parameters' actual values in a combinatorial way, until a combination gives back at least one row or all combinations are unsuccessfully tried. For instance, I may have this sequence of values:
(V1,V2,V3);
(V1,V2,"");
(V1,"",V3);
(V1,"","");
where V1, V2, V3 may by string values and V1 is always present, not null, and not blank in each combination.
A first strategy may be to prepare the statement, clear the parameters each time I execute the query, until stop condition is met.
I wonder if may be more efficient transform the query into
SELECT F1, F2, F3 FROM MYTABLE WHERE F1 = V1
and cycling over the cursor and, for each cursor row, verify if the returned tuple (F1,F2,F3) matches the combination (V1x,V2x,V3x). When at least 1 rows matches, or all combination are done, I'll exit iteration.
View Replies
ADVERTISEMENT
Jan 11, 2014
In the following Java Code:
public static void f() {
int n = 5;
p(n, 2 * n);
}
public static void p(int a, int b) {
int x = 1;
q(x, a + b);
}
public static void q(int x, int y) {
int z = x + y;
x = 0;
...
} mh_sh_highlight_all('java');
When we write x = 0; that refers to the formal parameter int x and hence it's the formal parameter that changes value. why isn't the value of the actual parameter also changing?
View Replies
View Related
Jun 3, 2014
public static void main(String[] args) {
System.out.println("VALUE Types");
int i = 5;
int j = 11;
System.out.println("i = " + i + ", j = " + j);
[Code] ....
Questions based on the code:
1. Identify all of the actual parameters in the code provided.
(Is it just i, j iArray and jArray)???
2. Identify all of the formal parameters in the code provided.
3. What is displayed in the third println statement?
i = 11, j = 2001
4. What is displayed in the fifth println statement?
iArray = 6 7 2001 9 10, jArray = 6 7 2001 9 10
View Replies
View Related
Jul 16, 2014
My understanding was I could override a method from the superclass, including with different parameters, but when I try to use super. it gives me an error the arguments have to match the superclass. But, if I do that it won't make any sense.
The first code below is the superclass. The issue I'm having is on the second code at lines 7 and 10. The ultimate goal is to make a new class where I'm able to display various packages with or without insurance.
public class Package {
double shippingWeight;
public char shippingMethod;
final char air = 'A';
final char truck = 'T';
final char mail = 'M';
double shippingCost;
[code]....
View Replies
View Related
May 20, 2014
I'd like to make a simple cheat for an old game that's offline... It has no type of anti-cheat and I'd like to make a program that changes how much money you have... I think the first thing I have to do is get the data address or something like that by using cheat engine... How do I do that? After that how do I start using that info in my program and then send back a new value? Are there any classes that I should be importing and what methods do I use to do this?
View Replies
View Related
Jul 26, 2014
I'm trying to change the value of bricks in my save file and for some reason it can't read the information.
public void addRecords(int brick, int log, int stone, int house){
x.format("%s%s
%s%s
%s%s
%s%s", "brick", " "+brick, "log", " " +log, "stone", " "+stone, "house", " "+house);
}
This writes information to my files. ^
public void addResource(String resource, int amount){
openFile();
readfile check = new readfile();
switch(resource){
case "brick":
[Code] .....
In my case "brick", It doesn't set the value when I try to read it. Here is the readResource method.
public int readResource(String resource){
System.out.println("Looking for " + resource);
String res = resource;
openFile();
while(x.hasNext()){
[Code] ....
Short version:
brick = check.readResource("brick");
This doesn't set brick to any value.
View Replies
View Related
Apr 1, 2014
I'm making a program for school that reads a text file with answers to a personality test and prints the temperament to an output file. Problem is, it sets the temperament for the first person to INFJ and then prints INFJ for the rest of the people too. My code is below, and the input file 'personality.txt' goes like this:
Betty Boop
BABAAAABAAAAAAABAAAABBAAAAAABAAAABABAABAAABABABAABAAAAAABAAAAAABAAAAAA
Snoopy
AABBAABBBBBABABAAAAABABBAABBAAAABBBAAABAABAABABAAAABAABBBBAAABBAABABBB
Bugs Bunny
[Code] ....
This is my Code :
public static void main(String[] args) throws FileNotFoundException {
welcome();
Scanner input = new Scanner(new File("personality.txt"));
PrintStream out = new PrintStream(new File("output.txt"));
int[][] outcome = new int[4][2];
double[] percent = new double[4];
[Code] .....
View Replies
View Related
May 23, 2012
I'm trying to create a Servlet that takes input from a form and process it and insert it in database.tablename.
My MAIN ISSUE IS WITH THE NUMBER OF COLUMNS THAT WOULD BE DYNAMIC AND THUS CANT RECEIVE THE PARAMETERS IN STATIC CODE.
Here is the form code
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<form action="Test" method="post" />
<table width="90%" border="1" cellspacing="1" cellpadding="1">
[Code] ....
And here is the Servlet
import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;
import java.io.*;
public class Test extends HttpServlet {
[Code] ....
This is the basic code structure and I'm trying to figure out this special case with handling the multiple parameters:
I don't want to use String []a=request.getParameterValues("studentname"); as hard code. The reason being the number of rows will be diyamic and I would like to get the column name and then then use an array of string to take values. But how can I connect these to form a query so that the rows goes on inserted one after other.
View Replies
View Related
Jan 31, 2014
I wrote a Chess game that uses socket to connect to another computer, and allow player vs player and player vs computer game sessions.
However, there is a problem which I noticed.
When you get the IP address of the computer in which the program is running, you are not getting the computer's actual IP, you are getting the Router's IP.
Is there a way to get around this.
So the problem is that when I go to another computer, located in a different house or lets say from my school, the program cannot connect back to my home IP, because it uses the router's ip, not the computer's ip I am running the server program.
Is there a way to get the Computer's IP, not the router's ip when summoning or invoking the get IP address method from the socket class?
When I say that the socket class is acquiring the router's ip, well that's done without my interfering...I don't know why it does that, it is somehow recognizing the router and not the computer.
The thing is that the server program is written that any client program is able to connect to the home server.
But when I run the program from a different location other than the current home, the sockets don't connect because it is somehow recognizing the router's ip not the computer's ip.
View Replies
View Related
Jun 6, 2010
This is my code-
<%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*" errorPage="" %>
<body>
<center>
<form>
<table border="0">
<tr> <td> bulbtype </td>
<td> <input type="text" name="bulbtype"></td> </tr>
[Code] ....
Im getting this error:
An error occurred at line: 24 in the jsp file: /bulb1.jsp
bulbwatts cannot be resolved
21: Statement stmt=conn.createStatement();
22: Statement st=conn.createStatement();
23: ResultSet rs1 = stmt.executeQuery("select * from bulb where type="+bulbtype);
24: ResultSet rs2 = st.executeQuery("select * from bulb where watts="+bulbwatts);
25: %>
26: <%while(rs1.next()){%>
27: <tr> <td>name1</td>
View Replies
View Related
May 7, 2014
I have an applet that uses JPanels to draw images in. I want to include actual jpgs now instead. The applet points to a .jar file. I want to use any number of images here, do I have to include them all in the jar file or is there another way to "point" to them (like html)?
View Replies
View Related
Oct 11, 2014
Ok so I know how to import a csv using java. What I'm curious about doing is importing a csv using file chooser, reading the data, sorting the data out by certain parameters, and then outputting a count of each parameter I chose. Say for example I have columns 1,2 and 3. Column 1 has the name, column 2 has the percentage, column 3 has an o'clock time. I want to use queries to sort through the parameters and have a count of each parameter I choose...
View Replies
View Related
Oct 7, 2014
Lately I've been working with JDBC and writing queries in some Java programs. I've noticed that I keep experimenting with where I place my blocks of querying code. I've tried creating a private method in the class where the query is used, I've created utility classes where I can call the query when needed, and sometimes I've just put it in a localized block of code where I need to. Also, most often these queries are one-shot queries where I need to pull the data to populate a JTable.
In short, this has made me realize that I don't have a solid practice for organizing my queries in Java. So my question is "Is there a practice for organizing query code?".
View Replies
View Related
Jul 2, 2014
I am new to JSTL and JSP & I am running 2 seperate SQL queries from a java/jsp program and I need to display the results from both queries on one JSP page output.Currently I have java code that passes the 2 queries to a method along with passing the jsp files to output the query results
- the method dispatches the results to these 2 JSP pages using JSTL tags in hope for separate output results:
I need to have a way to display these 2 outputs into 1 jsp page: - currently one just overwrites the other.I also tried using the jstl core <c: tags in 2 separate methods on the same jsp page but the <c: tags just resulted in overwriting one another - The queries run and display fine except I cannot get them both to display correctly.using jstl and jsp for displaying multiple queries on the same page.example: the jsp file that runs the queries:
runQuery.jsp:
<%
String query1 = "SELECT * FROM TABLE A";
String query2 = "SELECT * FROM TABLE B";
runReport(query1...,viewResults1.jsp)
runReport(query2...,viewResults2.jsp)
%>
[code]....
View Replies
View Related
Feb 5, 2013
javax.xml.parsers.DocumentBuilder can build a document from a single stream which is the XML file. However, I can't find any way to also give it a schema file.
Is there a way to do this so that my XPath queries can perform type aware queries and return typed data?
We presently use dom4j/jaxen and it does this fine but I figure we should switch to the standard Java runtime if this has been added.
View Replies
View Related
Jan 12, 2014
Below is part Two the method I need creating:
This method updates the sequence of stars according to the actual English word and the guess character.
public static String updateSecretWord(String secretWord, String englishWord, String guessedChar)
{
}
Below is the example of how it should look like when I call it
updateSecretWord(“*****”, “Hello”, “h”) = h****
updateSecretWord(“h****”, “Hello”, “o”) = h***o
updateSecretWord(“he**o”, “Hello”, “e”) = he**o
View Replies
View Related
Nov 12, 2014
I have one problem regarding Running Multiple queries parallely and storing results in resultsets . I have multiple queries but I need to executing all at a time without having to wait for one query to complete execution and then run another as there are 2 queries say query1 takes 10 mins and hence query2 should also start simultaneously and not wait for query 1 for completion.
String query1="select * from knowledge_rep";
String query2="select * from events";
ResultSet rs=null;
PreparedStatement ps =con.prepareStatement(query1);
rs=ps.executeQuery();
ps =con.prepareStatement(query2);
rs1=ps.executeQuery();
[Code] ....
The above one is time consuming and second implementation using branch i wont be able to resolve it to result set using execute batch. Considering there are multiple select queries and the number of queries to be executed are dynamic and unknown and all the data from the queries are needed. Any leads to perform all these by running multiple threads simantaneously.
View Replies
View Related
Jan 10, 2014
My friends and me are trying to make online Test taking system. We got a very basic doubt.
We have developed classes and relationship between classes for example : Online Test Taking system will have admin and student class. And Admin will have list of students.. etc.
But question troubled me was: if we use database to store all data for example student details then I can perform all sorts of operations writing sql query and store result in some other database then what is the need of "ArrayList<Student> field in Admin".??
Question is: We can put everything in database and manipulate using database(sql) functions to manipulate it.Then what is the need of Arraylist of anything which is just used to store object details for example student details....??
View Replies
View Related
Apr 15, 2014
For example I create an object like this:
BankAccount b = new SavingsAccount();
Now lets say that I want to access a method 'addInterest()' that is in the 'SavingsAccount' class I would have to do: '((SavingsAccount)s).addInterest();'
The question I have is why do I have to cast 'b' to SavingsAccount? Isn't the actual object reference of 'b' already an instance of 'SavingsAccount' class? How does the 'BankAccount' affect the object itself? I'm really confused as to what class is truly getting instantiated and how BankAccount and SavingsAccount are both functioning to make the object 'b'.
View Replies
View Related
Aug 29, 2014
I need a way to store the pixels values currently on the screen and compare them to the values on the first frame. Right now I'm using glreadpixels as follows:
currentBuffer= BufferTools.reserveByteData(mapSize);
glReadPixels(mapStartX, mapStartY, mapWidth, mapHeight, GL_BLUE, GL_UNSIGNED_BYTE, currentBuffer);
for (int i = 0; i < mapSize; i++) {
if (currentBuffer.get(i) != baseBuffer.get(i)) {
//Do nothing
continue;
}
//Do something
}
This works perfectly fine but turns out to be a real bottleneck, dropping the fps to a third of what it was. Is there any quicker way? All I'm after is speed, I don't even need to show it on the screen if the comparison is made "behind the scene".
View Replies
View Related
Feb 27, 2015
I have a question in mind that this is my registration form. I am sending these values from HTML form to server and database. I have question that in my case if I click next to Add Another Mobile no in HTML.then a block is genereated and each time a new name is generated.
My Question is if I click 6 times then 6 name attribute are generated. How can I send and differentiate them on my server side.
Because at their I will use something request.getAttribute("Attr_Name");
But they are same. How to do this?.
View Replies
View Related
Aug 25, 2014
i would like from my bean to redirect after an operation is completed to the page faces/test.xhtml?id=2? Is there a way to do this?
View Replies
View Related
Aug 2, 2014
So I created this line class and when I try to create Line object with parameters, I don't know how to pass the parameters properly. It has to return two points, so it should be like [(1,2),(5,12)].I tried different things likeLine l1=new Line(Point p1(1,2),Point p2(5,12)); and similar, but nothing worked.
package line;
import java.awt.Point;
public class Line {
private Point p1;
private Point p2;
[code]...
View Replies
View Related
Jan 31, 2015
public class TestClass {
public TestClass(String k){System.out.println(k);}
public static void main(String[] args) {
try {
hello();
}
catch(Exception e){System.out.println(e);}
[Code] ....
Explain how to catch block act as constructor with parameter?
View Replies
View Related
Mar 1, 2015
I have this JAVA written but I can't get the parameters for the if statements right.
import java.util.Scanner;
public class myFirstJAVA {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.println("Please enter command: ");
String text = input.nextLine();
[Code] ....
View Replies
View Related
Sep 12, 2014
I'm trying to pass a parmeter to a jsf page from a servlet(i.e. associated with paypal adaptive api), but I keep getting the following error, even though the productType on ProductDetailsVO is a String.
INFO: WARNING: FacesMessage(s) have been enqueued, but may not have been displayed.
sourceId=j_idt2[severity=(ERROR 2), summary=(j_idt2: '45;productType=Sport'
must be a number consisting of one or more digits.), detail=(j_idt2: '45;productType=Sport' must be a number between -2147483648 and 2147483647 Example: 9346)]
Calling JSF page contains:-
returnURL = new URL(new URL(request.getRequestURL().toString()),"pages/paypalpaymentapproved.xhtml?paypalID="+paypalID+";productType=Sport");
response.sendRedirect(returnURL.toString());
[Code] ....
View Replies
View Related