• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to draw points with coordinates from database

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would be grateful for some examples.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Karol Dziedzic
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Bartender
Posts: 2270
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Show us some code, i.e. what you have done so far.
 
Karol Dziedzic
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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) } } }
 
Bartender
Posts: 5465
212
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Many thanks;) I will check it;)
 
And then the flying monkeys attacked. My only defense was this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic