|
Mostrar Mensajes
|
Páginas: [1] 2
|
1
|
Programación / PHP / Problema con conexion de Yii Framework a SQLServer
|
en: 29 Enero 2016, 15:16 pm
|
Estoy intentando conectar Yii con SQLSERVER y me sale este error. CDbException CDbConnection failed to open the DB connection.
Esto es lo que tengo en el COMMON/Config/main.php <?php 'preload' => array('log', 'bootstrap'), 'frontend' => dirname(__FILE__) . '/../..' . '/frontend', 'common' => dirname(__FILE__) . '/../..' . '/common', 'backend' => dirname(__FILE__) . '/../..' . '/backend', 'vendor' => dirname(__FILE__) . '/../..' . '/common/lib/vendor', 'bootstrap' => dirname(__FILE__) . '/../..' . '/common/lib/vendor/clevertech/yii-booster/src', 'auth' => dirname(__FILE__) . '/../..' . '/backend/modules/auth' ), 'common.extensions.components.*', 'common.components.*', 'common.helpers.*', 'common.models.*', 'application.controllers.*', 'application.extensions.*', 'application.helpers.*', 'application.models.*', 'common.gii.*' ), 'language' => 'es', //'behaviors' => array('LanguageBehavior'), //'connectionString' => 'sqlite:'.dirname(__FILE__).'/../data/testdrive.db', //'connectionString' => 'mysql:host=192.168.0.117;dbname=yiiBase', 'connectionString' => 'sqlsrv:server=SOPORTE03\SQLEXPRESS;database=seguimiento', //'emulatePrepare' => true, 'username' => 'sa', 'password' => 'jean1234', //'charset' => 'utf8', 'tablePrefix' => 'dbo.', ), 'errorAction' => 'site/error', ), 'class' => 'common.lib.vendor.clevertech.yii-booster.src.components.Bootstrap', ), 'class' => 'CLogRouter', 'class' => 'CDbLogRoute', 'connectionID' => 'db', 'levels' => 'error, warning', ), ), ), ), // php configuration 'php.defaultCharset' => 'utf-8', 'php.timezone' => 'UTC', ) );
|
|
|
3
|
Programación / Java / error en consulta sql en java!
|
en: 21 Octubre 2015, 19:51 pm
|
Alguien sabe porque me sale este error? He tratado de solucionarlo pero de momento no he podido !!! Saludos!!! java.sql.SQLException: Operation not allowed after ResultSet closed public int GenerarIDInfante(){ int IDGenerado=0; try { operaciones consulta=new operaciones(); //crea un objeto de la clase consulta ResultSet resultado=consulta.ConsultaBase("select count(*) as id from documentos"); // resultado.next(); IDGenerado=resultado.getInt("id"); // consulta.getStmt().close(); } catch (SQLException ex) { System.out.println(ex); } return IDGenerado+1; } Mod: No escribir en maýuculas
|
|
|
4
|
Programación / Programación C/C++ / Lectura de archivo log, error al eliminar IPs duplicadas!
|
en: 8 Junio 2015, 04:31 am
|
Tengo un problema al eliminar las direcciones IP que se repiten! #include <iostream> #include <cstdlib> #include <fstream> #include <ctime> #include <string> #include<cstdio> using namespace std; /* *Leer el log y extraer la primera dirección IP (nnn.nnn.nnn.nnn). *Guardar la dirección ip en una lista -evitar que se repite la dirección ip. *Resumir cuantas veces se repite cada ip y visualizar en un SVG el resumen. */ struct miDataStruct { string direccionIP; int id; }; struct nodo { miDataStruct datoDelNodo; nodo *ant; nodo *next; }; //PROTOTIPOS void archivos_lectura(nodo * list); int getPosition(string linea,int opcion,int ini); //FUNCIONES DE MI LISTA DOBLE nodo * new_list(); nodo * insert_right(nodo *list, nodo data); void printListAsc(nodo *head); void printListDesc(nodo *head); void printList( nodo* list); void borrarNodo(nodo **head, nodo *node); void removerDuplicado(nodo **head); int main () { nodo *head = new_list(); nodo *current = head; archivos_lectura(current); printList( current); removerDuplicado(&head); return 0; } nodo * new_list(){ nodo *newelement= new nodo; newelement->datoDelNodo.direccionIP = - 1 ; newelement->next = newelement; newelement->ant = newelement; return newelement; } void addList( nodo *list , string number){ nodo *newelement = new nodo; newelement->datoDelNodo.direccionIP = number; newelement->next = list; newelement->ant = list->ant; list->ant = newelement; newelement->ant->next = newelement; } void printListAsc(nodo *head) { nodo *current = head; while (current->next != head) { current = current->next; printList(current); } } void printListDesc(nodo *head) { nodo *current = head; //printNode(current); while (current->ant != head) { current = current->ant; printList(current); } } void printList( nodo* list){ nodo *head = list; nodo *current = list; int i=1; char caracter; while (current != head->ant){ current=current->next; cout<<"LINEA --------> "<<i++<<endl<<endl; cout<<"Numero de IP: "<<current->datoDelNodo.direccionIP<<endl; cout<<"__________________________________"<<endl<<endl; // caracter = getchar(); //getch(); } cout<< endl ; } // Proceso de los ficheros... //Obteniendo la posicion de los datos del .log int getPosition(string linea,int opcion,int ini){ int r; switch(opcion) { case 1: r = linea.find("UDP") + 4;break; case 2: r=linea.find(" ",ini);break; } // -----> En caso de mas parametros a obtener, mas case; <- return r; } void archivos_lectura(nodo * list) { nodo *current=list; string line; ifstream myfile ("firewall_1.log"); int p1,p2; string numero; nodo myDataIP; if (myfile.is_open()) { while ( getline (myfile,line) ) { p1 =getPosition(line,1,0); // p1=29 p2=getPosition(line,2,p1); numero=line.substr(p1,p2-p1); addList(current,numero); //cout << line << '\n'; } myfile.close(); } else cout << "Unable to open file"; } // FUNCIONES PARA ELIMINAR LOS DUPLICADOS void removerDuplicado(nodo **head) { if((*head)->next == NULL) return; nodo *current = *head; nodo *aux; while(current) { aux = current->next; while(aux) { if(current->datoDelNodo.direccionIP == aux->datoDelNodo.direccionIP) { borrarNodo(head, aux); } aux = aux->next; } current = current->next; } return; } void borrarNodo(nodo **head, nodo *node) { nodo *current = *head; nodo *ant = *head; if(node == *head) { if((*head)->next != NULL) { *head = (*head)->next; } return; } while(current) { if(current == node) { ant->next = current->next; return; } ant = current; current = current->next; } }
//aqui les adjunto el codigo completo con el archivo log para que lo abran como proyecto! https://mega.co.nz/#F!L8NSyIxZ!RZX98C_HXUVnnwaW30UYFwMod: No escribir en mayúsculas
|
|
|
5
|
Programación / Scripting / Error en busqueda en amplitud con python
|
en: 3 Junio 2015, 18:43 pm
|
He estado tratando de corregir el error pero no lo encuentro ... Me sale: while nodo.get_padre() != None: AttributeError: 'NoneType' object has no attribute 'get_padre' from arbol import Nodo def buscar_solucion_BFS(estado_inicial, solucion): solucionado = False nodos_visitados = [] nodos_frontera = [] nodoInicial = Nodo(estado_inicial) nodos_frontera.append(nodoInicial) while(not solucionado) and len(nodos_frontera) != 0: nodo = nodos_frontera.pop(0) #extraer nodo y anadirlo a visitados nodos_visitados.append(nodo) if nodo.get_datos() == solucion: #solucion encontrada solucionado = True return nodo else: #expandir nodos hijos dato_nodo = nodo.get_datos() #operador izquierdo hijo = [dato_nodo[1], dato_nodo[0], dato_nodo[2], dato_nodo[3]] hijo_izquierdo = Nodo(hijo) if not hijo_izquierdo.en_lista(nodos_visitados) and not hijo_izquierdo.en_lista(nodos_frontera): nodos_frontera.append(hijo_izquierdo) #operador central hijo = [dato_nodo[0], dato_nodo[2], dato_nodo[1], dato_nodo[3]] hijo_central = Nodo(hijo) if not hijo_central.en_lista(nodos_visitados) and not hijo_central.en_lista(nodos_frontera): nodos_frontera.append(hijo_central) #operador derecho hijo = [dato_nodo[0], dato_nodo[1], dato_nodo[3], dato_nodo[2]] hijo_derecho = Nodo(hijo) if not hijo_derecho.en_lista(nodos_visitados) and not hijo_derecho.en_lista(nodos_frontera): nodos_frontera.append(hijo_derecho) nodo.set_hijos([hijo_izquierdo, hijo_central, hijo_derecho]) if __name__ == "__main__": estado_inicial = [4, 2, 3, 1] solucion = [1, 2, 3, 4] nodo_solucion = buscar_solucion_BFS(estado_inicial, solucion) #mostrar resultado resultado = [] nodo = nodo_solucion while nodo.get_padre() != None: resultado.append(nodo.get_datos()) nodo = nodo.get_padre() resultado.append(estado_inicial) resultado.reverse() print resultado
|
|
|
6
|
Programación / Java / ayuda sencilla de applet
|
en: 13 Mayo 2015, 06:21 am
|
Mod: lee las reglas del foro, no debes escribir en mayúsculas, los codigos ven en etiquetas GeSHi, las cosas van en su respuesctivo subforo... tema corregido y movidosaludos, tengo un error en mi ejercicio y me gustaria que me ayuden a encontrar el problema; es sobre la resolucion de una ecuacion cuadratica con applets... /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ import java.applet.Applet; import java.awt.*; import java.applet.*; import java.awt.event.*; import java.lang.Math; /** * * @author */ /** * Initialization method that will be called after the applet is loaded into * the browser. */ Label l1, l2, l3, l4, l5 ; public void init() { // TODO start asynchronous download of heavy resources // --> DECLARANDO MIS ETIQUETAS Y CAJAS DE TEXTO l4 = new Label("Raiz 1"); l5 = new Label("Raiz 2"); // --> AÑADIENDO BOTONES Y LABELS add(l1); add(t1); add(l2); add(t2); add(l3); add(t3); add(b); //-->BOTON add(l4); add(t4); add(l5); add(t5); add(t6); add(t7); b.addActionListener(this); // TODO overwrite start(), stop() and destroy() methods } //-->OPERACIONES LOGICAS DEL BOTON CALCULAR // var a=num,b=num2,c=num3 double num =Double. parseDouble(t1. getText()); double num2 =Double. parseDouble(t2. getText()); double num3 =Double. parseDouble(t3. getText()); // descarga en la variable d el valor de b^2-4ac double d =(Math. pow(num2, 2.0)-(4*num *num3 )); // calcula las raices de la ecuación double raiz1 =((-num2 )+Math. sqrt(d ))/(2*num ); double raiz2 =((-num2 )-Math. sqrt(d ))/(2*num ); // compara la variable d if (d==0) { // las raices son igulaes t6.setText(""+raiz1); t7.setText(""+raiz2); } if (d>0) { // tiene 2 raices diferentes t6.setText(""+raiz1); t7.setText(""+raiz2); } if (d<0) //--> CONDICION DE VALORES IMAGINARIOS { t6.setText("IMAGINARIA"); t7.setText("IMAGINARIA"); } } //---> POSICIONANDO ENCABEZADO g.drawString("Resolucion Ecuación Cuadratica aX^2+bx+c=0", 10, 110); g.drawString("Lenguaje de Programacion", 11, 130); } }
|
|
|
8
|
Programación / Programación C/C++ / Problema al ordenar una Lista Doble(Lectura de XML)
|
en: 23 Febrero 2015, 03:21 am
|
Alguien podría ayudarme a corregir mi error; lo que pasa es que estoy intentando ordenar mi lista Doble que la hice a partir de la lectura de un archivo xml.(La lectura funciona correctamente). Todo funciona hasta que ejecuta la funcion de ordenar y ahi deja de funcionar! Les agradecería infinitamente si me ayudan a resolver este problema! Igual si encuentro la solución les aviso! Muchas Gracias de antemano! #include <iostream> #include <cstring> #include <fstream> #include <cstdlib>
using namespace std;
struct datos { string TITLE; string ARTIST; string COUNTRY; string COMPANY; float PRICE; int YEAR; };
struct node { datos data; node *left; node *right; };
string getTagName(string str); string getTagContent(string str); node * newList(); node * insert_right(node *list, datos nuevo_nodeo); void printList(node* list); void readXML(node *head); void sortList(node **lista, int rule, bool dsc) ;
int main() {
node *head = newList(); node *current = head;
//LEYENDO MI ARCHIVO XML readXML(head);
cout << "IMPRIMIENDO LISTA" << endl << endl; printList(head); // Todo funciona hasta que le incorpora la parte para ordenar y la aplicacion deja de funcionar en ese momento!! sortList( &head, 1, true ); // Ordenando por precio, pero no me funciona y no encuentro el error! return 0; }
node * newList() { node *nuevo; nuevo = new node; nuevo->data.ARTIST=-1; nuevo->data.COMPANY=-1; nuevo->data.COUNTRY=-1; nuevo->data.PRICE=-1; nuevo->data.TITLE=-1; nuevo->data.YEAR=-1; nuevo->right = nuevo; nuevo->left = nuevo; return nuevo; }
string getTagName(string str) { int posInit, posFin; int delta; posInit = str.find("<"); posFin = str.find(">"); delta = posFin - posInit; return str.substr(posInit + 1, delta - 1); }
string getTagContent(string str) {
int posInit, posFin; int delta; posInit = str.find(">"); posFin = str.find("</"); delta = posFin - posInit;
return str.substr(posInit + 1, delta - 1); }
node * insert_right(node *list, datos nuevo_nodeo) { node *nuevo; nuevo = new node;
nuevo->data.TITLE = nuevo_nodeo.TITLE; nuevo->data.ARTIST = nuevo_nodeo.ARTIST; nuevo->data.COUNTRY = nuevo_nodeo.COUNTRY; nuevo->data.COMPANY = nuevo_nodeo.COMPANY; nuevo->data.PRICE = nuevo_nodeo.PRICE; nuevo->data.YEAR = nuevo_nodeo.YEAR;
nuevo->left = list; nuevo->right = list->right; list->right = nuevo; nuevo->right->left = nuevo; return nuevo; }
void printList(node* list) { node *head = list; node *current = list;
while (head != (current = current->right)) { cout << "------------------------" << endl; cout << current->data.TITLE << endl; cout << current->data.ARTIST << endl; cout << current->data.COUNTRY << endl; cout << current->data.COMPANY << endl; cout << current->data.PRICE << endl; cout << current->data.YEAR << endl; }
}
void readXML(node *current) {
datos nuevo; string fileName = "cd_catalog.XML"; string line; string tagName; int posInit, posFin; int delta; int ban = 0; cout << "-----archivo XML->" << fileName << "--------" << endl << endl << endl; ifstream myFile((char*) fileName.c_str());
while (getline(myFile, line, '\n')) { tagName = getTagName(line);
if (ban == 0) { datos nuevo; //Para acceder a mi estructura facilmente! }
if (tagName.compare("TITLE") == 0) { nuevo.TITLE = getTagContent(line); ban++; } else if (tagName.compare("ARTIST") == 0) { nuevo.ARTIST = getTagContent(line); ban++; } else if (tagName.compare("COUNTRY") == 0) { nuevo.COUNTRY = getTagContent(line); ban++; } else if (tagName.compare("COMPANY") == 0) { nuevo.COMPANY = getTagContent(line); ban++; } else if (tagName.compare("PRICE") == 0) { nuevo.PRICE = atof(getTagContent(line).c_str()); ban++; } else if (tagName.compare("YEAR") == 0) { nuevo.YEAR = atoi(getTagContent(line).c_str()); ban++; }
if (ban == 6) { current = insert_right(current, nuevo); ban = 0; }
}
myFile.close(); }
void sortList(node **lista, int rule, bool dsc) {
// rule { 1 --> Price, 2 --> year, 3 --> Artis, 4 --> title }
node *lst = *lista;
node *sig;
datos temp;
//-- Boolean para validar situación de cambio ---// bool valid;
do {
sig = lst->right;
while (sig->right != NULL) {
switch (rule) {
case 1:
valid = dsc ? (lst->data.PRICE > sig->data.PRICE) : (lst->data.PRICE < sig->data.PRICE);
break;
case 2:
valid = dsc ? (lst->data.YEAR > sig->data.YEAR) : (lst->data.YEAR < sig->data.YEAR);
break;
case 3:
valid = dsc ? (lst->data.ARTIST > sig->data.ARTIST) : (lst->data.ARTIST < sig->data.ARTIST);
break;
case 4:
valid = dsc ? (lst->data.TITLE > sig->data.TITLE) : (lst->data.TITLE < sig->data.TITLE);
break;
}
if (valid) {
temp = lst->data;
lst->data = sig->data;
sig->data = temp;
}
sig = sig->right;
}
lst = lst->right;
} while (lst->right != NULL);
}
|
|
|
9
|
Programación / Programación C/C++ / Re: BUSCAR EL VALOR MAXIMO Y MINIMO DEL ARBOL BINARIO
|
en: 28 Julio 2014, 19:02 pm
|
Y como haria para mostrar las hojas y los nodos interiores del arbol?
//ESTA FUNCION ESTOY TRABAJANDO ..
int view_NodosInteriores(node *p){ if (p == NULL) return 0; else{ while (p->left != NULL && p->right != NULL) return p->datos.edad +view_NodosInteriores(p->right) + view_NodosInteriores(p->left);
} }
|
|
|
10
|
Programación / Programación C/C++ / BUSCAR EL VALOR MAXIMO Y MINIMO DEL ARBOL BINARIO
|
en: 27 Julio 2014, 00:09 am
|
/* * File: firstTree.cpp * Author: Estudiantes * * Created on 17 de julio de 2014, 06:49 PM * * */
//Necesito saber como sacar el valor máximo y mínimo del árbol binario que esta a //continuación graficado. El problema es que mi función solo toma los valores //extremos del arbol( izquierda y derecha) que son hojas!
#include <cstdlib> #include <iostream>
using namespace std;
/* * * * * * */
struct misDatos{ string nombre; int edad; int num; };
struct node{ misDatos datos; node *left; node *right; };
node * newTree(); node * insert(int data, string name);
int printPreOrden(node* ptr); int printRoot(node* head); int printPostOrden(node *ptr); int printInOrden(node *ptr); int findMinimumValueLEFT(node* node); int findMinimumValueRIGHT(node* node);
int size(node *node); //MAXIMO DE NODOS int maxALTURA(node *node); //ALTURA
node * insert_right( int data); node * insert_left( int data); int contar_hojas(node *p) ; int nodosInteriores(node *raiz );
node *max(node *n); node *min(node *n);
int MAXIMOprintPreOrden(node* ptr);
int main() { //ARBOL 1 node *raiz = newTree(); node *current = raiz; node *arbol=raiz; /* ----> GRAFICO DEL ARBOL BINARIO A / \ B C / \ / \ D E F G
*/ //A=10 //B=14 //C=16 //D=18 //E=20 //F=24 //G=30 arbol->left = insert(14,"B"); arbol->right = insert(16,"C");
current=arbol->left; current->left = insert(50,"D"); current->right = insert(60,"E");
current=arbol->right; current->left = insert(24,"F"); current->right = insert(30,"G"); cout << "\tR E C O R R I D O P R E - O R D E N\n"; printPreOrden(raiz);
//cout<<endl<<endl; // cout << "\tR E C O R R I D O P O S T - O R D E N\n"; //printPostOrden(raiz); //cout<<endl<<endl; //cout << "\tR E C O R R I D O I N - O R D E N\n"; // printInOrden(raiz); cout<<endl<<endl<<endl<<endl; cout<<"NUMERO DE NODOS: "<<size(raiz)<<endl; cout<<"ALTURA : "<<maxALTURA(raiz)<<endl; cout<<"NUMERO DE HOJAS: "<<contar_hojas(raiz)<<endl; cout<<"NODOS INTERIORES: "<<nodosInteriores(raiz)<<endl; return 0; }
//---------------> NEW TREE node * newTree() { node *nuevo; nuevo = new node; nuevo->datos.nombre= "A"; nuevo->datos.edad = 10; // nuevo->right = nuevo; nuevo->left = nuevo;
return nuevo; }
// -------------> INSERTANDO node* insert(int data, string name) { node *nuevo; nuevo = new node; nuevo->datos.edad=data; nuevo->datos.nombre=name; nuevo->left=NULL; nuevo->right=NULL;
return nuevo; }
// -------------> O R D E N A M I E N T O S
// -----> PREORDEN
int printPreOrden(node* ptr) { node *current = ptr; printRoot(current); //RAIZ if(current->left!=NULL){ printPreOrden(current->left); //IZQUIERDA } if(current->right!=NULL){ printPreOrden(current->right); //DERECHA } return current->datos.edad; }
int printPostOrden(node *ptr){ node *current= ptr; if(current->left!=NULL){ printPostOrden(current->left); //IZQUIERDA }
if(current->right!=NULL){ printPostOrden(current->right); //DERECHA } printRoot(current); }
int printInOrden(node *ptr){ node *current= ptr; if(current->left!=NULL){ printInOrden(current->left); //IZQUIERDA } printRoot(current); if(current->right!=NULL){ printInOrden(current->right); //DERECHA } }
//numero de nodos int size(node *node){ if(node==NULL) return 0; else return (size(node->left)+1+size(node->right)); } //altura del arbol int maxALTURA(node *node){ if(node==NULL) return 0; else{ int s=maxALTURA(node->left); int m=maxALTURA(node->right); if (s>m) return (m+1); else return (s+1); }return (size(node->left)+1+size(node->right)); }
//IMPRIMIENDO RAIZ
int printRoot(node* head) { cout<<"Nombre: "<<head->datos.nombre<<" Edad: "<< head->datos.edad<<"\n"<<endl; }
//VALORES MAXIMOS Y MINIMOS ERRONEOS node *min(node *n) { if (n == NULL || n->left == NULL) return n; else return min(n->left); }
node *max(node *n) { if (n == NULL || n->left == NULL) return n; else return max(n->left); }
//-----> CONTAR HOJAS int contar_hojas(node *p){ if (p == NULL) return 0; else if (p->left == NULL && p->right == NULL) return 1; else return contar_hojas(p->left) + contar_hojas(p->right); }
//NODOS INTERIORES int nodosInteriores(node *raiz ){ return size(raiz)-contar_hojas(raiz); }
|
|
|
|
|
|
|