|
Mostrar Temas
|
Páginas: [1] 2 3
|
2
|
Programación / Bases de Datos / Es verdad que mysql es orientado a objetos?
|
en: 2 Diciembre 2011, 23:10 pm
|
Eso, un profesor habló conmigo y dijo que mysql era orientado a objetos, que se podian crear clases y que las columnas podian guardar objetos, estuve buscando info relacionada y solo encontre clases php que manejan mysql, ¿es esto cierto o es parte de la descabellada fantasía de mi profesor o es mi ineptitud la que no me permitió encontrar documentacion?
De antemano, gracias por sus respuestas
|
|
|
3
|
Programación / PHP / [PHP + JSP] Es posible?
|
en: 2 Diciembre 2011, 21:19 pm
|
Hola, estuve leyendo en un libro que se podía mezclar java con php, en el servidor tomcat, dejo el extracto del libro: Introduccion: The relationship between PHP and Java has changed significantly with each new release. Unsurprisingly, given the source code, PHP initially had much more in common with C. PHP4 supported integration of PHP and Java using a Java Servlet environment or, more experimentally, directly into PHP. Finally, with the overhaul of the object model in PHP5, there’s a distinctly Java feel to the PHP approach to object oriented programming. Java users will find much of PHP5’s new object model very familiar, though with important differences. Given these changes, as PHP takes on a more Java-like cast, there are two possibilities for which a discussion of PHP and Java might be pertinent. You might need to work on a project that requires PHP and Java or Java Server Pages (JSP) to work in tandem. Or you may be approaching PHP from a Java background and want to know about the similarities and differences in order to learn PHP faster. We will deal with both needs in this chapter. If you don’t have a need to use Java, or aren’t already
Expolicacion y ejemplo: Java Server Pages and PHP PHP can fulfill many functions similarly to Java Server Pages (JSP). The JSP servlet engine serves as a scripting language for use with Java, and, just as PHP, is often used in front end applications. Embedded HTML PHP is more similar to JSP than Java itself in that you are allowed to write HTML directly rather than using endless print statements. Unlike Java, but like JSP, variables can also be referenced from within a block of HTML. A simple HTML page using JSP script might look like this: <% String greeting = “Hello, world”; %> <HTML> <HEAD> <TITLE>Fun with JSP</TITLE> </HEAD> <BODY> <H1><%= greeting %></H1> </BODY> </HTML> Similarly, using PHP, you can write: <?php $greeting = “Hello, World”; ?> <HTML> <HEAD> <TITLE>Fun with PHP</TITLE> 722 Part IV ✦ Connections </HEAD> <BODY> <H1><?php echo $greeting ?></H1> </BODY> </HTML> Pages can freely alternate between HTML and JSP, just as in using HTML and PHP.
De antemano, gracias por sus respuestas. PD: Tengo el apache tomcat instalado, pero es la instalacion que viene por defecto, sinceramente no se por donde empezar, si alguien quiere el libro que me mande un mp y se lo mando por correo. 1083 paginas, esto de java+php empieza en la 719
|
|
|
4
|
Programación / Java / [Sockets] Sirven en internet?
|
en: 2 Diciembre 2011, 21:07 pm
|
Hola, estuve viendo unos videotutoriales que me paso un amigo, el tipo se llama nikitus y enseña a crear una conexion con sockets, en el video muestra como hacer un pequeño xat, todo el codigo funka, pero me gustaria saber si es posible hacer que funke en internet, traté de poner mi direccion ip en el programa cliente y pasarselo a un amigo, pero no funciono, codeé en base al video, dos clases, un cliente y un server, en localhost corre bien, pero me gustaría saber, si es posible, que debo cambiarle para que funcione en internet, de antemano gracias. Clase servidor: import java.net.ServerSocket; import java.net.Socket; import java.io.ObjectOutputStream; import java.io.IOException; import java.io.ObjectInputStream; import javax.swing.JOptionPane; public class XServer { private boolean isRunning=true; private volatile Command cmd=null; XServer(){ try{ s = ss.accept(); ioex.printStackTrace(); } this.sender(); this.receiver(); this.dealReceive(); this.autoClose(); } void sender(){ public void run(){ while(XServer.this.isRunning){ int type=0; try{ Command c=new Command(); c.setMsg(msg); type=(msg.equalsIgnoreCase("Close"))? 0:1; c.setType(type); oos.writeObject(c); ex.printStackTrace(); } if(type==0){ break; } } } }); t.start(); } void receiver(){ public void run(){ while(XServer.this.isRunning){ try{ if(aux!=null && aux instanceof Command){ XServer.this.cmd = (Command) aux; } intex.printStackTrace(); ioex.printStackTrace(); classex.printStackTrace(); } } } }); t.start(); } void dealReceive(){ public void run(){ while(XServer.this.isRunning){ try{ Command c=XServer.this.cmd; if(c.getType().equals("Message")){ System. out. println(c. getMsg()); }else if(c.getType().equals("Action") && c.getMsg().equals("Close")){ XServer.this.isRunning=false; } intex.printStackTrace(); }finally{ XServer.this.cmd=null; } } } }); t.start(); } void autoClose(){ public void run(){ while(true){ try{ if(!XServer.this.isRunning){ XServer.this.ois.close(); XServer.this.oos.close(); XServer.this.s.close(); } intex.printStackTrace(); ioex.printStackTrace(); } } } }); t.start(); } }
Clase cliente: import java.net.Socket; import java.io.ObjectOutputStream; import java.io.IOException; import java.io.ObjectInputStream; import javax.swing.JOptionPane; public class XClient { private boolean isRunning=true; private volatile Command cmd=null; XClient(){ try{ s =new Socket("10.5.4.124", 9999); ioex.printStackTrace(); } this.sender(); this.receiver(); this.dealReceive(); this.autoClose(); } void receiver(){ public void run(){ while(XClient.this.isRunning){ try{ if(aux!=null && aux instanceof Command){ XClient.this.cmd = (Command) aux; } intex.printStackTrace(); ioex.printStackTrace(); classex.printStackTrace(); } } } }); t.start(); } void dealReceive(){ public void run(){ while(XClient.this.isRunning){ try{ Command c=XClient.this.cmd; if(c.getType().equals("Message")){ System. out. println(c. getMsg()); }else if(c.getType().equals("Action") && c.getMsg().equals("Close")){ XClient.this.isRunning=false; } intex.printStackTrace(); }finally{ XClient.this.cmd=null; } } } }); t.start(); } void sender(){ public void run(){ while(XClient.this.isRunning){ int type=0; try{ Command c=new Command(); c.setMsg(msg); type=(msg.equalsIgnoreCase("Close"))? 0:1; c.setType(type); oos.writeObject(c); ex.printStackTrace(); } if(type==0){ break; } } } }); t.start(); } void autoClose(){ public void run(){ while(true){ try{ if(!XClient.this.isRunning){ XClient.this.ois.close(); XClient.this.oos.close(); XClient.this.s.close(); } intex.printStackTrace(); ioex.printStackTrace(); } } } }); t.start(); } }
Se me olvidaba, para lo que quiero hacer despues de aprender a manipular sockets en internet creé una clase comando, que en el futuro me servirá para mandar solo strings con referencias a lo que se debe hacer y no mandar objetos pesados a traves de la conexion, esta es la clase: import java.io.Serializable; private String[] types ={"Action", "Message", "Dialog", "Input", "Warning", "Error"}; private String[] actions ={"Close"}; Command(){ this.type= types[1]; } this.type=this.types[0]; this.msg=msg; } Command (String msg, int type ){ this.type=this.types[type]; this.msg=msg; } return msg; } this.msg=msg; this.type=types[2]; } this.msg=msg; this.type=types[3]; } this.msg=msg; this.type=types[4]; } this.msg=msg; this.type=types[5]; } public void setMsg (String msg ) { this.msg = msg; } public void setType(int i){ this.type=this.types[i]; } return this.type; } }
Bueno, de antemano agradezco muchísimo vuestras respuestas, saludos
|
|
|
5
|
Programación / Bases de Datos / [MYSQL] Otra forma de hacer esta consulta?
|
en: 11 Noviembre 2011, 21:45 pm
|
Hola, tengo la siguiente base de datos en mysql: CREATE DATABASE IF NOT EXISTS verduleros; DROP TABLE IF EXISTS ventas2; CREATE TABLE ventas2( idventa INT NOT NULL PRIMARY KEY, vendedor VARCHAR(255) NOT NULL, producto VARCHAR(255) NOT NULL, fecha DATE NOT NULL, kilos INT NOT NULL )engine=innodb;
La consulta que quiero realizar segun el planteamiento es: "Desplegar la suma de los kilos de cada producto que ha vendido cada vendedor" Para ello pense en la siguiente consulta: SELECT v.vendedor, v.producto, SUM(v.kilos) FROM ventas2 AS v WHERE v.kilos IN (SELECT kilos FROM ventas2 WHERE vendedor=v.vendedor AND producto=v.producto) GROUP BY vendedor ;
El problema es que la base de datos es muy grande xD, probé la lógica de esta consulta en una tabla pequeña y funciona, pero en la base de datos que nos entregó el profe esperé alrededor de unos 20 minutos y no me mostró nada, lo intenté en reiteradas veces, probé a reiniciar el pc y nada, la base de datos es muy grande por lo tanto no puedo hacer esto con subconsultas (y, pensandolo, si la consulta por si sola se demora, hacer por cada fila una subconsulta es descabellado xD), se los agradecería enormemente si es posible hacer esto de otra forma. Saludos!
|
|
|
6
|
Programación / PHP / [PHP-MYSQL] Como crear un sp en php?
|
en: 1 Noviembre 2011, 02:03 am
|
Hola estoy intentando crear un procedimiento almacenado desde php a mysql, que estoy haciendo mal? <html> <head> </head> <body> <?php create procedure pedir(in strCodBicicleta varchar(255), in strCodPeticion varchar(255), in strCodUsuario varchar(255)) begin update bicicleta set estado='usando' where cod_bicicleta=strCodBicicleta; insert into peticion(cod_peticion, usuario, fecha, hora)values(strCodPeticion, strCodUsuario, current_date, current_time); end "); if($b){ echo "funka"; }else{ echo "T_T"; } ?> </body> </html>
Dejo las tablas bicicleta, peticion y usuario:
De antemano, gracias PD: en la shell funka con el uso de delimiter
|
|
|
7
|
Programación / PHP / [MYSQL] Error con consulta [SOLUCIONADO]
|
en: 31 Octubre 2011, 05:52 am
|
Hola tengo un problemilla con la sintaxis de una funcion, me he qebrado la cabeza todo el dia tratando de ver que es, se supone que hay un registro que tiene el dato 'BC3' que debiera tomar la consulta "select * from b_disponibles" (la cual es una vista), el caso es que al mostrar me muestra 0 me conecto a la base de datos de tal forma: He probado mostrar si la conexion funka, me muestra que si
La funcion que me retorna el resultset es la siguiente: function getAvailableBicicles(){ return $r; }
Luego trato de hacer lo tipico con el resultset: $row2=getAvailableBicicles(); $val = $fila['cod_bicicleta']; echo $val," <br>"; }
El nombre de la columna esta bien escrito, he probado con fetch_assoc, fetch_row y nada, me muestra 0 siendo que en la tabla no hay ningun registro con ese valor  Dejo la tabla bicicletas:
La vista bicicletas libres:
Finalmente los inserts:
Antes de la creacion de las tablas esta la creacion de bases de datos y su uso xD (por si acaso)
De antemano, gracias por sus respuestas. PD: En la shell de mysql funka 
|
|
|
8
|
Programación / PHP / Header, como se usa
|
en: 11 Octubre 2011, 23:43 pm
|
Buenas, he visto que para redireccionar a una pag despues de cierto tiempo usan:
header("Location: pagina.php");
El caso es que no me funka cuando trabajo en la misma pagina, ¿esta mal trabajar con un solo archivo php?
De antemano, gracias, saludos!
|
|
|
9
|
Programación / Java / [GregorianCalendar] ¿Como saber cual es el primer día del mes?
|
en: 23 Agosto 2011, 01:41 am
|
Hola, estoy haciendo una aplicación para manejar horarios, la gui la hice de tal forma que al pasarle desde donde hasta donde son los días del mes de x año me genera una ventana con los 42 JLabels con su día asignado, ahora bien, lo que necesito es cómo saber que día empieza x mes, para esto creé una subclase de GregorianCalendar, a la cual llamé ZCalendar, los métodos más importantes que me interesería saber si están bien hechos son getFirtsDayOfMonth() y getLastDayOfMonth(), lo que pasa es que a veces se me corre un día el calendario si pudieran decirme que estoy haciendo mal estaría bastante agradecido. package horario; import java.util.HashMap; import java.util.Calendar; import java.util.GregorianCalendar; /** * Clase para obtener los datos necesarios para construir la interfaz grafica <code> Meses </code> * * @param año Los datos del objeto se crearan a pertir del año dado * @param mes Los datos del objeto se crearan a pertir del mes dado * @author Zero */ int[] dias={g.MONDAY, g.TUESDAY, g.WEDNESDAY,g.THURSDAY,g.FRIDAY,g.SATURDAY,g.SUNDAY}; /** * Arreglo utilizado para saber que día termina cada mes del año */ int[] last={31, 28, 31,30,31,30,31,31,30,31,30,31}; /** * Indica el año con que se construye este objeto */ int y=0; /** * Usado para conocer que indice tendra cada mes del año en el arreglo <code>last[]</code> */ HashMap<Integer, String> mez=null; /** * Indica el mes con que se construye este objeto */ int m=0; /** * Indica el primer día del mes */ int first=0; ZCalendar(int año, int mes){ this.set(ZCalendar.YEAR, año); this.set(ZCalendar.MONTH, mes); m=mes; mez=new HashMap<Integer, String>(); y=año; int w=0; mez.put(w, "Enero"); w++; mez.put(w, "Febrero"); w++; mez.put(w, "Marzo"); w++; mez.put(w, "Abril"); w++; mez.put(w, "Mayo"); w++; mez.put(w, "Junio"); w++; mez.put(w, "Julio"); w++; mez.put(w, "Agosto"); w++; mez.put(w, "Septiembre"); w++; mez.put(w, "Octubre"); w++; mez.put(w, "Noviembre"); w++; mez.put(w, "Diciembre"); w++; } /** * Devuelve la posicion del <code>ZLabel</code> desde donde empezarán los días del mes */ int getFirstDayOfMonth(){ int d=0; this.set(this.DAY_OF_MONTH, this.DAY_OF_MONTH - this.DAY_OF_MONTH); d=this.get(this.DAY_OF_WEEK); d++; first=d; return d; } /** * Devuelve la posicion del <code>ZLabel</code> en donde terminarán los días del mes */ int getLastDayOfTheMonth(){ int x=0; if(m==1){ return inFeb(); } if(last[m]==30){ return in30(); } if(last[m]==31){ return in31(); } return x; } private int in30(){ switch(first){ case 0: return 29; case 1: return 30; case 2: return 31; case 3: return 32; case 4: return 33; case 5: return 34; case 6: return 35; case 7: return 36; } return 10; } private int in31(){ switch(first){ case 0: return 30; case 1: return 31; case 2: return 32; case 3: return 33; case 4: return 34; case 5: return 35; case 6: return 36; case 7: return 37; } return 10; } private int inFeb(){ if(isBis(y)){ switch(first){ case 0: return 28; case 1: return 29; case 2: return 30; case 3: return 31; case 4: return 32; case 5: return 33; case 6: return 34; case 7: return 35; } }else{ switch(first){ case 0: return 27; case 1: return 28; case 2: return 29; case 3: return 30; case 4: return 31; case 5: return 32; case 6: return 33; case 7: return 34; } } return 10; } /** * Devuelve <code>true</code> si <code>x</code> es multiplo de 4 * * @param x Representa el año que se desea saber si es bisiesto */ boolean isBis(int x){ if(x%4==0){ return true; }else{ return false; } } /** * Devuelve el nombre del mes correspondiente * * @return m El nombre del mes con el que se construye este objeto */ return mez.get(this.m); } /** * Devuelve el año correspondiente * * @return m El año con el que se construye este objeto */ return y+""; } }
Saludos
|
|
|
10
|
Programación / Java / [VBS] ¿Como hacer esto en java? [InternetExplorer.application]
|
en: 30 Julio 2011, 01:09 am
|
Hola, bueno verán, quiero mostrar un code en vbs, lo explicaré paso a paso y me gustaría saber si es posible hacer lo mismo en java set ie=createobject("internetexplorer.application") 'se crea un objeto para manipular el internetexplorer ie.navigate("http://www.google.com") 'como podran imaginar se navega en la url dada s=inputbox("Ingresa tu busqueda") ' se abre un cuadro de dialogo para ingresar un valor del usuario ie.visible=true 'se hace visible la ventana del explorer do 'ok este bucle sirve para que, si el internetexplorer se está cargando, esperar 'nada más if ie.busy then wscript.sleep 5000 else exit do end if loop set b=ie.document.getelementbyid("lst-ib") 'se obtiene la barra de texto de google b.value=s 'se escribe lo que el usuario ingresó en la barra set b2=ie.document.getelementbyid("btnG") 'se obtiene el boton "buscar con google" b2.click() 'se hace click en el boton "buscar con google"
Existe alguna forma de hacer lo mismo con java? Que librerías me recomiendan investigar? De antemano, gracias  Saludos 
|
|
|
|
|
|
|