Search Results

Search found 1291 results on 52 pages for 'persistence ignorance'.

Page 10/52 | < Previous Page | 6 7 8 9 10 11 12 13 14 15 16 17  | Next Page >

  • PHP Database connection practice

    - by Phill Pafford
    I have a script that connects to multiple databases (Oracle, MySQL and MSSQL), each database connection might not be used each time the script runs but all could be used in a single script execution. My question is, "Is it better to connect to all the databases once in the beginning of the script even though all the connections might not be used. Or is it better to connect to them as needed, the only catch is that I would need to have the connection call in a loop (so the database connection would be new for X amount of times in the loop). Yeah Example Code #1: // Connections at the beginning of the script $dbh_oracle = connect2db(); $dbh_mysql = connect2db(); $dbh_mssql = connect2db(); for ($i=1; $i<=5; $i++) { // NOTE: might not use all the connections $rs = queryDb($query,$dbh_*); // $dbh can be any of the 3 connections } Yeah Example Code #2: // Connections in the loop for ($i=1; $i<=5; $i++) { // NOTE: Would use all the connections but connecting multiple times $dbh_oracle = connect2db(); $dbh_mysql = connect2db(); $dbh_mssql = connect2db(); $rs_oracle = queryDb($query,$dbh_oracle); $rs_mysql = queryDb($query,$dbh_mysql); $rs_mssql = queryDb($query,$dbh_mssql); } now I know you could use a persistent connection but would that be one connection open for each database in the loop as well? Like mysql_pconnect(), mssql_pconnect() and adodb for Oracle persistent connection method. I know that persistent connection can also be resource hogs and as I'm looking for best performance/practice.

    Read the article

  • Setting a parameter as a list for an IN expression

    - by perilandmishap
    Whenever I try to set a list as a parameter for use in an IN expression I get an Illegal argument exception. Various posts on the internet seem to indicate that this is possible, but it's certainly not working for me. I'm using Glassfish V2.1 with Toplink. Has anyone else been able to get this to work, if so how? here's some example code: List<String> logins = em.createQuery("SELECT a.accountManager.loginName " + "FROM Account a " + "WHERE a.id IN (:ids)") .setParameter("ids",Arrays.asList(new Long(1000100), new Long(1000110))) .getResultList(); and the relevant part of the stack trace: java.lang.IllegalArgumentException: You have attempted to set a value of type class java.util.Arrays$ArrayList for parameter accountIds with expected type of class java.lang.Long from query string SELECT a.accountManager.loginName FROM Account a WHERE a.id IN (:accountIds). at oracle.toplink.essentials.internal.ejb.cmp3.base.EJBQueryImpl.setParameterInternal(EJBQueryImpl.java:663) at oracle.toplink.essentials.internal.ejb.cmp3.EJBQueryImpl.setParameter(EJBQueryImpl.java:202) at com.corenap.newtDAO.ContactDaoBean.getNotificationAddresses(ContactDaoBean.java:437) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at com.sun.enterprise.security.application.EJBSecurityManager.runMethod(EJBSecurityManager.java:1011) at com.sun.enterprise.security.SecurityUtil.invoke(SecurityUtil.java:175) at com.sun.ejb.containers.BaseContainer.invokeTargetBeanMethod(BaseContainer.java:2920) at com.sun.ejb.containers.BaseContainer.intercept(BaseContainer.java:4011) at com.sun.ejb.containers.EJBObjectInvocationHandler.invoke(EJBObjectInvocationHandler.java:203) ... 67 more

    Read the article

  • php variable scope

    - by Illes Peter
    I have two files: index.php /lib/user.php Index contains the form: <div class="<? echo $msgclass; ?>"> <? echo $msg; ?> </div> <form id="signin" action="/lib/user.php" method="post"> ... </form> User.php makes all the processing. It sets $msg to 'some error message' and $msgalert to 'error' in case of any error. At the end of processing it uses header() to redirect to index.php But after redirection $msg and $msgalert get out of scope and index only gets empty vars. How can i fix this?

    Read the article

  • ASP.NET MVC Session usage

    - by Ben
    Currently I am using ViewData or TempData for object persistance in my ASP.NET MVC application. However in a few cases where I am storing objects into ViewData through my base controller class, I am hitting the database on every request (when ViewData["whatever"] == null). It would be good to persist these into something with a longer lifespan, namely session. Similarly in an order processing pipeline, I don't want things like Order to be saved to the database on creation. I would rather populate the object in memory and then when the order gets to a certain state, save it. So it would seem that session is the best place for this? Or would you recommend that in the case of order, to retrieve the order from the database on each request, rather than using session? Thoughts, suggestions appreciated. Thanks Ben

    Read the article

  • Included php file calling Javascript function

    - by Illes Peter
    Hi there! Here's the deal. I've got index.php which links to an internal JS file in it's header. index.php then includes another .php file, which outputs this: + add file. addFile() is a Javascript function defined in the external JS file. By doing this nothing happens, the included php does not "see" the JS function. Encapsulating the JS in the included PHP makes it all work. But I don't want to do it that way. Any ideas? EDIT: here's the source <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Archie</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <link rel="stylesheet" href="/screen.css" type="text/css" media="screen"/> <script src="/lib/js/archie.js" type="text/javascript"></script> </head> <body> ... ... //included php starts here <form action="/lib/course.php" method="post"> <fieldset> <div id="addFileLocation"></div> <a href="#" onClick="addFile()">+ add file</a> <input type="hidden" id="addFileCount" value="0"/> </fieldset> </form> //ends here ... ... </body> </html> and the js: <script type="text/javascript"> //Dynamically add form fields //add file browser function addFile() { var location = document.getElementById('addFileLocation'); var num = document.getElementById('addFileCount'); var newnum = (document.getElementById('addFileCount').value -1)+ 2; num.value = newnum; var newname = 'addFile_'+newnum; var newelement = document.createElement('input'); newelement.setAttribute('name',newname); newelement.setAttribute('type','file'); location.appendChild(newelement); } </script>

    Read the article

  • What data formats does PowerShell most easily read ?

    - by Jim
    I'm trying to use PowerShell with SharePoint. I'd like my PowerShell scripts to load my SharePoint farm configuration from files rather than either hard coding the configuration in the scripts, or having to pass in the same parameters each time. This the kind of information I need to store. WebFrontEnds: Web1, Web2, Web3 CentralAdmin: Central1 Index: Web1 ContentWebApps: http://user1, http://user2 Does PowerShell easily load this data from CSV, XML, or other formats?

    Read the article

  • Correct way to persist Quartz triggers

    - by davioooh
    I'm quite new to Quartz and now I need to schedule some jobs in Spring Web App. I know about Spring + Quartz integration (I'm using Spring v 3.1.1) but I'm wondering if it's the right way to follow. In particular I need to persist my scheduled tasks in a DB so I can re-initialize them when application is restarted. Are there some utilities provided by Spring scheduling wrapper to do this? Can you suggest me some "well known" approach to follow?

    Read the article

  • How do I do automatic data serialization of data objects in Haskell

    - by Adam Gent
    One of the huge benefits in languages that have some sort of reflection/introspecition is that objects can be automatically constructed from a variety of sources. For example in Java I can use the same objects for persisting to a db (with Hibernate) serializing to XML (with JAXB) or serializing to JSON (json-lib). You can do the same in Ruby and Python also usually following some simple rules for properties or annotations for Java. Thus I don't need lots "Domain Transfer Objects". I can concentrate on the domain I am working in. It seems in very strict FP like Haskell and Ocaml this is not possible. Particularly Haskell. The only thing I have seen is doing some sort of preprocessing or meta-programming (ocaml). Is it just accepted that you have to do all the transformations from the bottom upwards? In other words you have to do lot of boring work to turn a data type in haskell into JSON/XML/DB Row object and back again into a data object.

    Read the article

  • Why two subprocesses created by Java behave differently?

    - by Lily
    I use Java Runtime.getRuntime().exec(command) to create a subprocess and print its pid as follows: public static void main(String[] args) { Process p2; try { p2 = Runtime.getRuntime().exec(cmd); Field f2 = p2.getClass().getDeclaredField("pid"); f2.setAccessible(true); System.out.println( f2.get( p2 ) ); } catch (Exception ie) { System.out.println("Yikes, you are not supposed to be here"); } } I tried both C++ executable and Java executable (.jar file). Both executables will continuously print out "Hello World" to stdout. When cmd is the C++ executable, the pid is printed out to console but the subprocess gets killed as soon as main() returns. However, when I call the .jar executable in cmd, the subprocess does not get killed, which is the desired behavior. I don't understand why same Java code, with different executables can behave so differently. How should I modify my code so that I could have persistent subprocesses in Java. Newbie in this field. Any suggestion is welcomed. Lily

    Read the article

  • getting data from tableviewcell to 2nd view

    - by chubsta
    I am very new to this and am trying to learn by creating a few little apps for myself. I have a navigation-based app where the user taps the row to select a film title - i then want the second view to show details of the film. Thanks to a very helpful person here i am getting the results of the row pressed as 'rowTitle' as follows : (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { NSString *key = [keys objectAtIndex:indexPath.section]; NSArray *nameSection = [names objectForKey:key]; NSString *rowTitle = [nameSection objectAtIndex:indexPath.row]; NSLog(@"rowTitle = %@", rowTitle); [tableView deselectRowAtIndexPath:indexPath animated:YES]; I am, however, struggling to make the data at 'rowTitle' available to the 2nd view - basically, if i can get the info - for example rowTitle is "aliens2" - i want to be able to add a new extension to the end of the string returned by 'rowTitle' in order to point to an image (if that makes sense) in the second view... something like tempImageName=[** this is where the info from rowTitle needs to be i suppose**]; tempImageType=@".png"; finalImageName=[tempImageName stringByAppendingString:tempImageType]; does this make sense to anyone (apologies if it doesnt - i know what i want but how to explain it is a little more awkward!) Thanks again for any help anyone can give (and any help as to formatting these questions would be useful too obviously!!)!

    Read the article

  • MVC Persist Collection ViewModel (Update, Delete, Insert)

    - by Riccardo Bassilichi
    In order to create a more elegant solution I'm curios to know your suggestion about a solution to persist a collection. I've a collection stored on DB. This collection go to a webpage in a viewmodel. When the go back from the webpage to the controller I need to persist the modified collection to the same DB. The simple solution is to delete the stored collection and recreate all rows. I need a more elegant solution to mix the collections and delete not present record, update similar records ad insert new rows. this is my Models and ViewModels. public class CustomerModel { public virtual string Id { get; set; } public virtual string Name { get; set; } public virtual IList<PreferredAirportModel> PreferedAirports { get; set; } } public class AirportModel { public virtual string Id { get; set; } public virtual string AirportName { get; set; } } public class PreferredAirportModel { public virtual AirportModel Airport { get; set; } public virtual int CheckInMinutes { get; set; } } // ViewModels public class CustomerViewModel { [Required] public virtual string Id { get; set; } public virtual string Name { get; set; } public virtual IList<PreferredAirporViewtModel> PreferedAirports { get; set; } } public class PreferredAirporViewtModel { [Required] public virtual string AirportId { get; set; } [Required] public virtual int CheckInMinutes { get; set; } } And this is the controller with not elegant solution. public class CustomerController { public ActionResult Save(string id, CustomerViewModel viewModel) { var session = SessionFactory.CurrentSession; var customer = session.Query<CustomerModel>().SingleOrDefault(el => el.Id == id); customer.Name = viewModel.Name; // How cai I Merge collections handling delete, update and inserts ? var modifiedPreferedAirports = new List<PreferredAirportModel>(); var modifiedPreferedAirportsVm = new List<PreferredAirporViewtModel>(); // Update every common Airport foreach (var airport in viewModel.PreferedAirports) { foreach (var custPa in customer.PreferedAirports) { if (custPa.Airport.Id == airport.AirportId) { modifiedPreferedAirports.Add(custPa); modifiedPreferedAirportsVm.Add(airport); custPa.CheckInMinutes = airport.CheckInMinutes; } } } // Remove common airports from ViewModel modifiedPreferedAirportsVm.ForEach(el => viewModel.PreferedAirports.Remove(el)); // Remove deleted airports from model var toDelete = customer.PreferedAirports.Except(modifiedPreferedAirports); toDelete.ForEach(el => customer.PreferedAirports.Remove(el)); // Add new Airports var toAdd = viewModel.PreferedAirports.Select(el => new PreferredAirportModel { Airport = session.Query<AirportModel>(). SingleOrDefault(a => a.Id == el.AirportId), CheckInMinutes = el.CheckInMinutes }); toAdd.ForEach(el => customer.PreferedAirports.Add(el)); session.Save(customer); return View(); } } My environment is ASP.NET MVC 4, nHibernate, Automapper, SQL Server. Thank You!!

    Read the article

  • Save file info in program c#

    - by rubentjeuh
    Hello, Is it possible to save some fields in the program, or do I have to write them to a file? Example: 1) I open a file (with OpenFileDialog) and put it in a FileInfo 2) close the program 3) restart the program 4) go to open - recent - select the previous File Thanks

    Read the article

  • What is the relationship between IRimTable and PersistenceStore?

    - by Martin
    The BlackBerry Desktop API has the interface IRimTable which apparently maps an "application database" on a BlackBerry device to a virtual structure (i.e, IRimTable has IRimRecords, each of which has IRimField) that developer can browse the handheld device data when it is connected to a desktop computer. Meanwhile, applications in the handheld device can store its data in PersistenceStore databases. The point where I'm stuck is the PersistenceStore API doesn't define any Table or Records or Fields. Does anybody knows what is the relationship between these two classes? And how does the mapping work (if at all) ?

    Read the article

  • Why is the EntityManager in my GAE + Spring (+graniteds) project reset to null?

    - by prefabSOFT
    Hi all, I'm having a problem with autowiring my EntityManager. Actually at server startup I can see that the injection works ok, though when trying to use my EntityManager it appears to be null again. @Component public class DataDaoImpl { protected EntityManager entityManager; @Autowired public void setEntityManager(EntityManager entityManager) { System.out.println("Injecting "+entityManager); //works! this.entityManager = entityManager; } public void createData(String key, String value) { System.out.println("In createData entityManager is "+entityManager); //entityManager null!? ... Output: Injecting org.datanucleus.store.appengine.jpa.DatastoreEntityManager@a60d19 The server is running at http://localhost:8888/ In createData entityManager is null So somehow the autowired entityManager is reset to null when trying to use it. It's a graniteds powered project though I don't think this is graniteds related. Any ideas? Thanks a lot in advance, Jochen

    Read the article

  • Best way to store data for Greasemonkey based crawler?

    - by Björn
    I want to crawl a site with Greasemonkey and wonder if there is a better way to temporarily store values than with GM_setValue. What I want to do is crawl my contacts in a social network and extract the Twitter URLs from their profile pages. My current plan is to open each profile in it's own tab, so that it looks more like a normal browsing person (ie css, scrits and images will be loaded by the browser). Then store the Twitter URL with GM_setValue. Once all profile pages have been crawled, create a page using the stored values. I am not so happy with the storage option, though. Maybe there is a better way? I have considered inserting the user profiles into the current page so that I could all process them with the same script instance, but I am not sure if XMLHttpRequest looks indistignuishable from normal user initiated requests.

    Read the article

  • HSQLDB and in-memory files

    - by lewap
    Is it possible to setup HSQLDB in a way, so that the files with the db information are written into memory instead of using actual files? I want to use hsqldb to export some data structures together with hibernate mappings. Is is, however, not possible to write temporary files, so that I need to generate the files in-memory and return a stream with their contents as a response. Setting hsqldb to use nio seems not to be a solution, because there is no way to get hold of those files before they get written onto the filesystem. What I'm thinking of is a protocol handler for hsqldb, but I didn't find a suitable solution yet. Just to describe in other words: A hack solution would be to pass hsqldb a stream or several streams. It would then during its operation write data into those streams. After all data is written, the user of the db could then use those streams to send it back over the network.

    Read the article

  • Strategy to keep track of stored files in the documents directory?

    - by mystify
    In my app, the user can save his input to disk. This is done with NSKeyedArchiver. Currently I simply name my files with a timestamp. But of course, the user may want to load one of them back in to keep on editing them. What would be the most reliable / safe strategy to keep track of those files? I need to present the user a list of those files, so that he can choose one to open. Currently I think of making an archived NSMutableArray which simply stores the file names, but I feel that this strategy is not really good. We all know when we save files sometimes something goes wrong, and this seems very likely to get currupted easily, or not? How would you do it?

    Read the article

  • How to do multiple column UniqueConstraint in hbm?

    - by DataSurfer
    Working on some legacy hibernate code. How do I do the following with hbm.xml(hibernate mapping file) instead of with annotations? @Table(name="users", uniqueConstraints = { @UniqueConstraint(columnNames={"username", "client"}), @UniqueConstraint(columnNames={"email", "client"}) }) public class User implements Serializable { private static final long serialVersionUID = 1L; @Id private int id; private String username; private String email; private Client client; }

    Read the article

  • XMLEncoder and PersistenceDelegate

    - by Johannes Rössel
    I'm trying to use XMLEncoder to write an object graph (tree in my case) to a file. However, one class contained in it is not actually a Java bean and I don't particularly like making its guts publicly accessible. It's accessed more like a list and has appropriate add methods. I've already written a custom PersistenceDelegate to deal with that. However, is there any way for XMLEncoder to pick it up on its own or do I really need to add it whenever I use an encoder to write a graph that may contain said class?

    Read the article

  • netbeans + hibernate for java swing application

    - by blow
    Hi all, im developing a java swing app and i would use hibernate for persistance. Im totally new in jpa, hibernate and ORM in general. Im follow this tutorial, its easy but the problem is the java class that descrive a table in db are made from the table with reverse enginering. I want do the opposite process: i want make db table from the java class. The question is, how can i do this with netbeans? There are some tutorial?

    Read the article

  • How do I save a transient object that already exists in an NHibernate session?

    - by Daniel T.
    I have a Store that contains a list of Products: var store = new Store(); store.Products.Add(new Product{ Id = 1, Name = "Apples" }; store.Products.Add(new Product{ Id = 2, Name = "Oranges" }; Database.Save(store); Now, I want to edit one of the Products, but with a transient entity. This will be, for example, data from a web browser: // this is what I get from the web browser, this product should // edit the one that's already in the database that has the same Id var product = new Product{ Id = 2, Name = "Mandarin Oranges" }; store.Products.Add(product); Database.Save(store); However, trying to do it this way gives me an error: a different object with the same identifier value was already associated with the session How do I get around this problem?

    Read the article

  • Google App Engine update an object from servlet not working ?

    - by Frank
    I use the following code to update an object from servlet in Google App Engine : String Time_Stamp=Get_Date_Format(6),query="select from "+Contact_Info_Entry.class.getName()+" where Contact_Id == '"+Contact_Id+"' order by Contact_Id desc"; PersistenceManager pm=null; try { pm=PMF.get().getPersistenceManager(); // note that this returns a list, there could be multiple, DataStore does not ensure uniqueness for non-primary key fields List<Contact_Info_Entry> results=(List<Contact_Info_Entry>)pm.newQuery(query).execute(); Contact_Info_Entry A_Contact_Entry=results.get(0); A_Contact_Entry.Extra_10=Time_Stamp; pm.makePersistent(A_Contact_Entry); } catch (Exception e) { Send_Email(Email_From,Email_To,"Check_License_Servlet Error [ "+Time_Stamp+" ]",new Text(e.toString()+"\n"+Get_Stack_Trace(e)),null); } finally { pm.close(); } The value "[ 2010-05-13 Thu 15:58:31 ]" was in A_Contact_Entry.Extra_10, but it seems "pm.makePersistent(A_Contact_Entry);" was not executed. The object was not updated and there was no error message, why ? How to fix it ?

    Read the article

  • Efficient persistent storage for simple id to table of values map for java

    - by wds
    I need to store some data that follows the simple pattern of mapping an "id" to a full table (with multiple rows) of several columns (i.e. some integer values [u, v, w]). The size of one of these tables would be a couple of KB. Basically what I need is to store a persistent cache of some intermediary results. This could quite easily be implemented as simple sql, but there's a couple of problems, namely I need to compress the size of this structure on disk as much as possible. (because of amount of values I'm storing) Also, it's not transactional, I just need to write once and simply read the contents of the entire table, so a relational DB isn't actually a very good fit. I was wondering if anyone had any good suggestions? For some reason I can't seem to come up with something decent atm. Especially something with an API in java would be nice.

    Read the article

< Previous Page | 6 7 8 9 10 11 12 13 14 15 16 17  | Next Page >