Foros del Web » Programación para mayores de 30 ;) » Java »

Rellenar array y utilizar

Estas en el tema de Rellenar array y utilizar en el foro de Java en Foros del Web. Buenas; Hola tengo el siguiente código: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"/> <title> Cuadro de Mandos ...
  #1 (permalink)  
Antiguo 23/12/2010, 09:45
 
Fecha de Ingreso: junio-2010
Mensajes: 24
Antigüedad: 13 años, 10 meses
Puntos: 0
Rellenar array y utilizar

Buenas;

Hola tengo el siguiente código:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title>
Cuadro de Mandos
</title>
<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load('visualization', '1', {packages: ['corechart']});
</script>
<script type="text/javascript">
function drawVisualization() {
// Create and populate the data table.
var data = new google.visualization.DataTable();


data.addColumn('string', 'x');

data.addColumn('number', 'Tempe');
data.addColumn('number', 'Tempe3');

//Bucle para rellenar la tabla del grafico

for (i = 0; i < 3;i++)
{
data.addRow(["a",3256 , 3265]);
}

// Create and draw the visualization.
new google.visualization.LineChart(document.getElement ById('visualization')).
draw(data, {curveType: "function",
width: 500, height: 400,
vAxis: {maxValue: 10}}
);
}


google.setOnLoadCallback(drawVisualization);
</script>
</head>
<body style="font-family: Arial;border: 0 none;">
<%@ page import="java.sql.*" %>
<%@ page import="java.util.*" %>

<%
//Conexion Access2007
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newI nstance();
String sRutaBD = "C:/trans/datos.accdb";
//String sRutaBD = getServletContext().getRealPath("C:/Users/JuanCarlos/BD/datos.accdb");
String sConexion = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=" + sRutaBD + ";";
Connection cnJDBC = DriverManager.getConnection(sConexion);
Statement stJDBC = cnJDBC.createStatement();
String sSQL = "SELECT * FROM TotalEnvios";
ResultSet rs = stJDBC.executeQuery(sSQL);

//int[] iArrayTempe={25151,21515,98958};
//int[] iArrayTempe3={2515,8948,89647};

int i=0;
do {
if(rs.next())
{
i++;
out.print("Tempe3: " + rs.getString("Tempe3") + "<br />\n");
out.print("Tempe: " + rs.getString("Tempe") + "<br />\n");
//iArrayTempe[i]=rs.getString("Tempe3");
//iArrayTempe[i]=rs.getString("Tempe");
//iArrayTempe[i]={25616,565};
//iArrayTempe3[i]={115154,5151};
//out.print("Tempe: " + iArrayTempe[i] + "<br />\n");
//out.print("Tempe3: " + iArrayTempe3[i] + "<br />\n");
}
} while (rs.next()==true);
//Conexion Access
%>
<div id="visualization" style="width: 500px; height: 400px;"></div>
</body>
</html>

Es un Jsp que ejecuta un API de google y pint aun grafico. Tengo una BD se Access 2007 con una tabla con los datos. La conexion la hace bien y para probarlo hago un out.print para que me muestr los datos y lo hace.
Lo que quiero es guardar los datos en un Array y despues utilizar los valores del Array para el data.addRow(["a",3256 , 3265]); seria sustituir los numeros 3256 por los datos de los array.

No se como hacerlo:

Tengo que rellenar el array en ese momento y despues utilizarlo en el API. Lo estoy haceindo bien??

Gracias
  #2 (permalink)  
Antiguo 24/12/2010, 10:35
Avatar de BLEND  
Fecha de Ingreso: marzo-2006
Mensajes: 97
Antigüedad: 18 años, 1 mes
Puntos: 0
Respuesta: Rellenar array y utilizar

o.O me quedo un poco confundido.

Se supone que los datos los estas recibiendo en un ResultSet que esta funcionando como un arreglo a los cuales puedes accedes como bien lo tienes (rs.getString o tambien con rs.getInt).

Realmente creo que podrias hacerlo con el ResultSet que estas recibiendo, o creo que estoy entendiendo mal la pregunta.


Salu2...
__________________
.·´¯`·-> (3l£NÐ <-·´¯`·.

Etiquetas: rellenar, utilidades
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 08:34.