File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Other JSE/JEE APIs and the fly likes How to draw points with coordinates from database Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "How to draw points with coordinates from database" Watch "How to draw points with coordinates from database" New topic
Author

How to draw points with coordinates from database

Karol Dziedzic
Greenhorn

Joined: Jul 22, 2014
Posts: 8
I would be grateful for some examples.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61218
    
  66

Welcome to the Ranch.

Draw points where? In a browser? On a Swing app window?

Please TellTheDetails, and tell us exactly what part has you puzzled.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Karol Dziedzic
Greenhorn

Joined: Jul 22, 2014
Posts: 8
I extracted columns from database and made calculations inside while loop. I know i need to make array to get from it coordinates for points. I want to draw them in interface created in another class but i have black hole and don't know how to get datas from while loop to array which is below.
Swastik Dey
Rancher

Joined: Jan 08, 2009
Posts: 1477
    
    6

Show us some code, i.e. what you have done so far.


Swastik
Karol Dziedzic
Greenhorn

Joined: Jul 22, 2014
Posts: 8
import java.sql.*; import java.util.ArrayList; import javax.swing.*;

public class punkty { String serverName = ?; String database = ?; String user = ?; String password = ?; String JDBC= "com.mysql.jdbc.Driver"; String url = ?; public static void main(String[] args) throws SQLException, ClassNotFoundException {

Connection connection = DriverManager.getConnection(url, user, password); Statement s = null; Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver"); s = connection.createStatement();

String sql = "SELECT a, b ,c ,d FROM db"; ResultSet rs = s.executeQuery(sql); float a1,a2,b1,b2; float x,y; while(rs.next()){ a1 = rs.getFloat("a"); a2 = rs.getFloat("b"); x=a1+a2; // result: group of x points b1 = rs.getFloat("c"); b2 = rs.getFloat("d"); y=b1+b2; // result: group of y points

// What was the problem: // This code is working well but I dont know how to get values from while loop to make below steps

// Pn(xn,yn) - there is that many points as many probes // number of probes is changing very fast // I want to create array with x and y values // Using array create points which I will represent in existing interface created in another class (on button click) } } }
Piet Souris
Ranch Hand

Joined: Mar 08, 2009
Posts: 547
    
  11
hi Karol,

on this address you can find a complete demo of a scatter plot, including explanation:

http://math.hws.edu/javanotes/c13/s4.html

see section 13.4.3.

Greetz,
Piet
Karol Dziedzic
Greenhorn

Joined: Jul 22, 2014
Posts: 8
Many thanks;) I will check it;)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to draw points with coordinates from database