Comparing Data Across Different Database Programmatically?
Oct 22, 2014
I am looking to reconcile data between SQL server and Oracle DB post the migration, I need to verify the data (rows/columns) for last 10 years, Before i start writing a Java Utility to accomplish this, My question is are there any existing libraries or API which can accomplish the same ....
This program accepts Student ID numbers, Name, and grade point average. The problem I am having is with the if else statement that compares id to studentID[x]. I have tried to compare using if(id.equals(studentID[x])) and also I have tried using if(id == (studentID[x])) as shown in the code below. I keep getting incorrect results though.
//FILE: StudentIDArray.java import javax.swing.*; //Used for the JOption dialog boxes import java.util.*; //Used for Scanner input
I'm working on a project based on Roger Alsing's Mona Lisa evolution.
My problem seems to be that when I compare the RGB values of the target image and the randomly generated image, I don't get a representative result of how "close" the two images are.
I load the target image (a 24-bit bitmap) using:
img = ImageIO.read(new File(filePath));
I draw onto a BufferedImage with:
for(int i = 0; i < numPolys*12; i += 12){ p[(int)(i/12)].addPoint(gene[i], gene[i+1]); p[(int)(i/12)].addPoint(gene[i+2], gene[i+3]); p[(int)(i/12)].addPoint(gene[i+4], gene[i+5]); p[(int)(i/12)].addPoint(gene[i+6], gene[i+7]); Color mycol = new Color(gene[i+8], gene[i+9], gene[i+10], gene[i+11]); gf.setColor(mycol); gf.fillPolygon(p[(int)(i/12)]); }
And I compare the BufferedImage with the target image using:
for(int x = 0; x < inGene.x; ++x){ for(int y = 0; y < inGene.y; ++y){ Color mycol1 = new Color(exp.getRGB(x, y)); Color mycol2 = new Color(inImage.getRGB(x, y)); int delta = mycol1.getRed() - mycol2.getRed(); score += (delta * delta); delta = mycol1.getGreen() - mycol2.getGreen(); score += (delta * delta); delta = mycol1.getBlue() - mycol2.getBlue(); score += (delta * delta); } }
My problem is that my code runs to a certain point, where it seems no matter what happens to the image, it doesn't seem to get any closer to the target image.
I'm having serious issues right now with a JTable inside a JScrollPane.i have some methods that returns different indexes (rows) that i select programatically in a JTable and the problem is that sometimes it goes beyond of what i can see, like, the row gets selected but the scrollbar won't follow up.
i've searched up in google and saw several different methods but those were extremely complex and for stuff i don't need.the simplest solution i found is this:
but it just doesn't do anything.My table (tInfo) has only two columns so no horizontal bars, just vertical. What can i do to align the scrollbar with the currently selected row in my table? :C
Found a solution using scrollPane.getVerticalScrollBar().setValue();in another thread, i didn't even notice there were like 3 more threads about the same, just different kind of code used in each.
I am developing application called java compiler... It takes java program as input and compiles and run it, gives output. but if input program has infinite loop then how can identify and stop process execution.
I have a JScrollPane with a JTextArea. The JTextArea is loaded with 10 lines of data. I have two JCheckBox's. The first check box sets the scroll to 10. sp.getVerticalScrollBar().setValue(10); The second check box reloads (ta.setText(text)) the text and then sets the scroll to 10. Why does the second one not work? I have attached a simple program. It is probably easier for you to compile and run than for me to go into detail explaining further.
import java.awt.*; import java.awt.event.*; import javax.swing.*; public class Tester extends JFrame { private static final String text = "1
Why is my create jar file programatically not working? So doing this does create a jar file. When I run the jar file via command line, it gives me "Could not find or load main class ...". I'm not sure exactly why. I took some code i found here: java - How to use JarOutputStream to create a JAR file? - Stack Overflow and apparently it didn't specify the main class so I specifically added it myself. am i doing something wrong? And btw, the file (that contains all the class files) do not have any directories in them. so it's essentially just one folder with a bunch of class files in there. below is the code.
I had the commons-io-2.4 jar referenced into my build path that can be downloaded here: Commons IO - Download Commons IOreason i guess i added to that, though i'm not sure if it was necessary or not, was because it has a file filter which can tell which files are hidden or not and thing is without it it was adding like DS_STORE(which is hidden and i guess unnecessary) to the jar. not sure if this logic is right but just letting you know.
I am still working on my java course and now we have to create a jar file from a previous project (this is a project where a connection to the database is made and data is shown in a frame).
When I follow the instruction in my course material I don't get it to work. I've tried the following:
1. Open eclipse on windows xp 2. Right click on the project folder in eclipse 3. Click on "export" in the menu that appears 4. Choose "runnable jar" 5. click next 6. I insert the following parameters:
- Launch configuration --> I select my main class - export destination --> I select the folder D: - library handling --> Package required libraries into generated jar
7. click Finish
This is what happens when I dbl click the jarfile (wampserver is running):
1. I get an error: "SQL ERROR: Communications link failure The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server."
2. I click ok on the message and the following message appears: "SQL Error: null"
3. I click ok on this message and the frame with the fields appears without data from the database.
I can insert data to table by using JSP Scriptlet easily but I have a hard time with servlet.
public class UsertToDatabase() { public boolean inserUser(String name, String email, String pwd) throws SQLException { PreparedStatement pstmt = null; boolean flag = false; System.out.println("start"); openConn(); System.out.println("start_1"); if(conn == null) {
[code]....
I am positive that the above code function fine. The problem is whenever I call UserToDB() class inside the servlet, and I got this error: java.lang.ClassNotFoundException: org.postgresql.
Driver which mean that my conn (connection) is not connected to the database but I have ensure to do so by calling openConn() before start the transaction.
try { is = new FileInputStream(file); data = new byte[(int) file.length()]; is.read(data); String extension = ""; int i = file.getName().lastIndexOf('.'); if(i>0)
[Code] ....
Everything works except transferring the image file.
I need my java program to insert data into my access database. I get no errors in my code, but it never inserts, deletes the data in my database. Here is my code:
import java.awt.*; import java.awt.event.*; import java.sql.*; public class INS extends Frame implements ActionListener{ Frame f; Label l1, l2; TextField t1, t2; Button b1, b2, b3, b4, b5; Connection c;
I have tried this code to insert into datbase if not exists but i get an Exception in thread "main" com.mysql.jdbc. exceptions.jdbc4. MySQL SyntaxErrorException: 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 'WHERE NOT EXISTS (SELECT teamName FROM Teams WHERE teamName = teamName) LIMIT 1' at line 1
stmt.executeUpdate("INSERT INTO Teams(teamId,teamName,league) VALUES ("+i+",'"+loser+"','"+league2+"')WHERE NOT EXISTS (SELECT teamId,teamName,league FROM Teams WHERE teamName = teamName) LIMIT 1;");
I need getting detailed examples about how I can read/insert into database using JSF code for its different components. I am a beginner in JSF and I have the basics, however, I need the best source which it has useful, easy and detailed steps to understand the techniques for connecting to the DB and how to insert or read data from the database.
I tried to search, but I found the lessons are not useful or not described in details.
I have a simple project to save data to the database. I have successfully mapped the java class with the database table. The code displays no error, it runs very well but it does not save to database, instead it catches an exception and prints out "saving failed". The database is a mysql database.
This is the managed bean code. Save.java(name=bean)
//imports
@ManagedBean(name="bean") @RequestScoped public class Save { private String username,password,msg; Session session = null; Transaction transaction = null; //GETTERS AND SETTERS public Save() {
[Code] ....
This is a screenshot of my Hibernate configuration file : hb.jpg
I have a stylesheet (mystylesheet.css) with following entry:
.flowpane{ -fx-background-color: rgb(0,0,0); }
In then start-method of my application I execute:
StackPane root = new FlowPane(); Scene scene = new Scene(root,primaryScreenBounds.getWidth(),primaryScreenBounds.getHeight()); scene.getStylesheets().add(css.getFile()); root.applyCss();
No FlowPane gets black. But if I do that in SceneBuilder and add the stylesheet to root than after loading Fxml-file the FlowPane gets black.
Another approach:
StackPane root = new FlowPane(); Scene scene = new Scene(root,primaryScreenBounds.getWidth(),primaryScreenBounds.getHeight()); scene.getStylesheets().add(css.getFile()); root.getStyleSheets().add(css.getFile()); root.applyCss();
Nothing happens.
StackPane root = new FlowPane(); Scene scene = new Scene(root,primaryScreenBounds.getWidth(),primaryScreenBounds.getHeight()); scene.getStylesheets().add(css.getFile()); root.getStyleSheets().add(css.getFile()); root.getStyleClass().add("flowpanel"); root.applyCss();
Doesn't work too;
but root.setStyle("-fx-background-color: rgb(0,0,0) works. But I need to style my application by css-files.
I've tried everything but in vain..I want to save the data from the table into the database, I can easily connect to the database. All I want is how to get the values from the table. I've tried this method to get the values but its not working because of the contructor error in the BgTableModel class.
Tried Method public void writeBgEdu() { int last=gtm.getRowCount(); System.out.println(last); for( int i=0;i<last;i++) { if(((String) gtm.getValueAt(i,0))!=null)
I am trying to retrieve data from my database by joining my tables. So far i have managed to join my four tables in my database and retrieve all the information in that table. Now what i want to do is create a prepared statement in java that allows me to retreive certain data. Here is my joining query.
SELECT student.idNumber,student.names, student.surname, course.description, coursemarks.mark, class.form,class.id FROM `student` LEFT JOIN `coursemarks` on student.idNumber = coursemarks.studentid LEFT JOIN `course` on course.courseid = coursemarks.courseid LEFT JOIN `class`on student.idNumber = class.studentID;
What I want is to select all the data depending on the class passed and the form passed, e.g a person might decide to select a certain form only or a certain form and class