I'm new to JavaScript and have to build a jdbc application for school. I already have the database in Heidisql and made connection but I the error when I build it. I don't know what the next step is. I have created an arraylist. The error references line 25 in the repository code.  public class TechnicianRepository { private Connection connection;  public TechnicianRepository() {     try {         Class.forName("com.mysql.jdbc.Driver");         System.out.println("De Driver is geregistreerd!");         String URL = "jdbc:mysql://localhost/atm_installatie";         String USER = "root";         String PASS = "Br@h!em8891";         Connection conn = DriverManager.getConnection(URL, USER, PASS);         System.out.println(connection);         System.out.println();     } catch (ClassNotFoundException ex) {         System.out.println("Error: unable to load driver class!");         System.exit(1);     } catch (SQLException e) {         e.printStackTrace();     } }   public List&lt;Technician&gt; findAllRecords() {     List&lt;Technician&gt; technicianList = new ArrayList&lt;Technician&gt;();     Statement stmt = null;     try {         stmt = connection.createStatement();         String sql = "SELECT * FROM Technician";         ResultSet rs = stmt.executeQuery(sql);         System.out.println("Resultset: " + rs);         while (rs.next()) {             int tech_id = rs.getInt("tech_id");             String voornaam = rs.getString("voornaam");             String achternaam = rs.getString("achternaam");             String functie = rs.getString("functie");             String email_adres = rs.getString("email_adres");             String telefoonnummer = rs.getString("telefoonnummer");             System.out.println("Tech_ID: " + tech_id);             System.out.println("Voornaam: " + voornaam);             System.out.println("Achternaam: " + achternaam);             System.out.println("Functie: " + functie);             System.out.println("Email_Adres: " + email_adres);             System.out.println("TelefoonNummer: " + telefoonnummer);             technicianList.add(new Technician(tech_id, voornaam, achternaam, functie, email_adres, telefoonnummer));             technicianList.add(new Technician(rs.getInt("tech_id"), rs.getString("voornaam"), rs.getString("achternaam"), rs.getString("functie"), rs.getString("email_adres"), rs.getString("telefoonnummer")));         }         rs.close();      } catch (SQLException e) {      } finally {         //if (stmt != null) { stmt.close(); }      }     return technicianList; }          public class Applicatie { public static void main(String[] args) {     TechnicianRepository technicianrepo = new TechnicianRepository();     List&lt;Technician&gt; technicianList = technicianrepo.findAllRecords();     for (Technician technician : technicianList) {         System.out.println(technician);     }
129
What are Null Pointer Exceptions (java.lang.NullPointerException) and what causes them?  What methods/tools can be used to determine the cause so that you stop the exception from causing the program to terminate prematurely?
101821
while making a call from php i am getting the error      Attempt to de-reference a null object Class.Demo.Insert:   What is problem in my webservice?  global class Ctest{     global class RequestClass{         webservice String accName;     }      webservice static void   cInsert(RequestClass req){         Account a1 = new Account();         a1.Name = req.accName;         insert a1;     } }   And Our Php Code Is  require_once('salesforceAPI/soapclient/SforceEnterpriseClient.php'); require_once('salesforceAPI/soapclient/SforceHeaderOptions.php');  $sfdc = new SforceEnterpriseClient(); $SoapClient = $sfdc-&gt;createConnection('enterprise.wsdl.xml');  $loginResult = false;  $loginResult = $sfdc-&gt;login(USER, PASSWORD . SECURITY_KEY);  $parsedURL = parse_url($sfdc-&gt;getLocation()); define("_SFDC_SERVER_", substr($parsedURL['host'], 0, strpos($parsedURL['host'], '.'))); define("_WS_NAME_", 'salesforceAPI/Ctest'); define("_WS_WSDL_", _WS_NAME_ . '.xml'); define("_WS_ENDPOINT_", 'https://' . _SFDC_SERVER_ . '.salesforce.com/services/wsdl/class/' . _WS_NAME_); define("_WS_NAMESPACE_", 'http://soap.sforce.com/schemas/class/' . _WS_NAME_);  $client = new SoapClient(_WS_WSDL_); $sforce_header = new SoapHeader(_WS_NAMESPACE_, "SessionHeader", array("sessionId" =&gt; $sfdc-&gt;getSessionId())); $client-&gt;__setSoapHeaders(array($sforce_header));  $method = $client-&gt;__getFunctions();  $wsParams = array('accName' =&gt; 'XXXXXXX');  $client-&gt;cInsert($wsParams)
14914
I'm trying to get a postgres jdbc connection working in eclipse. It would be nice to use the Data Source Explorer, but for now I'm just trying to get a basic connection. What I have done so far is download the postgres JDBC connector. I then tried two different things. First, Preferences-> Data Management, I tried to add the postgres connector. Second, I added the jar to my project and tried to load the driver using Class.forName("org.postgresql.Driver"); but neither worked. Does anyone have any ideas?  Thanks,    Charlie
108487
I have the code below (I've included what I believe are all relevant sections):  private String readCommand = "SELECT LEVEL FROM USERS WHERE VAL_1 = ? AND VAL_@ = ?;"; public bool read(string id) {     level = -1;     MySqlCommand m = new MySqlCommand(readCommand);     m.Parameters.Add(new MySqlParameter("", val1));     m.Parameters.Add(new MySqlParameter("", val2));     MySqlDataReader r = m.ExecuteReader();     if (r.HasRows)         level = Convert.ToInt32(r.GetValue(0).ToString());     r.Close();     return true; }   When I run this, I get an IndexOutOfBoundsException on adding the first parameter. What have I done wrong?
58461
Consider the code:  PreparedStatement ps = null; ResultSet rs = null; try {   ps = conn.createStatement(myQueryString);   rs = ps.executeQuery();   // process the results... } catch (java.sql.SQLException e) {   log.error("an error!", e);   throw new MyAppException("I'm sorry. Your query did not work."); } finally {   ps.close();   rs.close(); }   The above does not compile, because both PreparedStatement.close() and ResultSet.close() throw a java.sql.SQLException.  So do I add a try/catch block to the finally clause?  Or move the close statements into the try clause?  Or just not bother calling close?
116296
Anytime I have to handle dates/times in java it makes me sad   I'm trying to parse a string and turn it into a date object to insert in a preparepared statement. I've been trying to get this working but am having no luck. I also get the helpful error message when I go to compile the class.  "Exception in thread "main" java.lang.Error: Unresolved compilation problem:  The method setDate(int, Date) in the type PreparedStatement is not applicable for the arguments (int, Date)"  Eh WTF?  Here is the offending code.  for(int i = 0; i &lt; flights.size(); i++){      String[] details = flight[i].toString().split(":");      DateFormat formatter ;      formatter = new SimpleDateFormat("ddMMyyyy");     Date date = formatter.parse(details[1]);       PreparedStatement pstmt = conn.prepareStatement(insertsql);     pstmt.setString(1, details[0]);     pstmt.setDate(2, date);     pstmt.setString(3, details[2] + "00");     pstmt.setString(4, details[3]);     pstmt.setString(5, details[4]);     pstmt.setString(6, details[5]);     pstmt.setString(7, details[6]);     pstmt.setString(8, details[7]);     pstmt.setString(9, details[8]);     pstmt.executeUpdate();  }
77839
when I try to run the code below I am getting this error: 'Too many DML rows: 10001'. The object that I am trying to update is one of the main object in the org. so it has multiples triggers, workflows, etc. and one API that runs all day long. I am trying to update 29000 records. can anybody please tell me why i am getting this error or if something is wrong with the code. I will appreciate any help!  Class code:     public class updateNRProdObject{    public Decimal Debug{ get; set; }         public void updateObject(){     List&lt;NRProducts__c&gt; products = [SELECT id  FROM NRProducts__c WHERE  Active__c = true];   Debug = products.size();    for(NRProducts__c p : products){       p.Active__c=false;    }    update products ;   } }
40938
After I posted this question, I found a similar post that seemed to answer it: . I'll leave this in place for now, as I am not sure how to mark my own question as a duplicate  In attempting to debug a SOQL query error, I encountered a strange behavior with Database.query and bind variables. Specifically, when I run this code:  String userQuery = 'SELECT Id FROM User'; if (true) {     List&lt;String&gt; firstNames = new List&lt;String&gt;{'James','Joe'};     userQuery += ' WHERE FirstName IN :firstNames'; } Database.query(userQuery);   the Database.query statement executes with no errors, despite the fact that the variable firstNames does not exist in its context. However, when I add an else clause:  String userQuery = 'SELECT Id FROM User'; if (true) {     List&lt;String&gt; firstNames = new List&lt;String&gt;{'James','Joe'};     userQuery += ' WHERE FirstName IN :firstNames'; } else {     List&lt;String&gt; firstNames; } Database.query(userQuery);   I receive a null object reference exception. It seems like Salesforce is checking to see if the variable is only declared once beforehand and, if so, uses its value in the context it was declared. This seems strange to me, so I was wondering if anybody here has any insight into what is going on under the hood.
61801
I'm new to Ubuntu, using 18.04 and trying to install Netbeans or Eclipse but neither of them works.  At first my java was version 10. Searching for solutions I found many suggestions to install version 8 so I installed that and changed my default java to 8, but I'm getting new errors.  Here is the error of eclipse which is in its configuration folder (after running eclipse from terminal, eclipse guided me there to see the error):  !SESSION Sat Jun 09 15:21:19 CEST 2018 ----------------------------------------- !ENTRY org.eclipse.equinox.launcher 4 0 2018-06-09 15:21:19.382 !MESSAGE Exception launching the Eclipse Platform: !STACK java.lang.ClassNotFoundException: org.eclipse.core.runtime.adaptor.EclipseStarter     at java.net.URLClassLoader.findClass(URLClassLoader.java:381)     at java.lang.ClassLoader.loadClass(ClassLoader.java:424)     at java.lang.ClassLoader.loadClass(ClassLoader.java:357)     at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:626)     at org.eclipse.equinox.launcher.Main.basicRun(Main.java:584)     at org.eclipse.equinox.launcher.Main.run(Main.java:1438)     at org.eclipse.equinox.launcher.Main.main(Main.java:1414)   Netbeans doesn't even give error messages - it just can't load.  Again I searched to see what is wrong it seems these applications even need older versions of java but I can't find any older version. (java doesn't support them)  Can someone please help?
111890
I am a complete JSP beginner.  I am trying to use a java.util.List in a JSP page.  What do I need to do to use classes other than ones in java.lang?
68403
I have this controller but I am getting this error      System.QueryException: List has no rows for assignment to SObject   public class MyController {     private final Account account;      public MyController() {         account = [SELECT Id, Name, Site FROM Account                     WHERE Id = :ApexPages.currentPage().getParameters().get('id')];             }      public Account getAccount() {         return account;     }      public PageReference save() {         update account;         return null;     } }
96142
I am working on a requirement to create an opportunity and opportunity products , when there is an update on the asset object.  The asset object has a filed called Refresh_Asset_To__c, this is a lookup to the product object.   Basically each time I change the product on the Refresh_Asset_To__c, a new opportunity should be generated with the Refresh_Asset_To__c being the opportunity product.  I have tested , and its generating the opportunity , but each time i try to insert the opportunity product I get the error :      Update failed. First exception on row 0 with id 02i3B000003TAk7QAG; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, AssetRefreshOpp: execution of AfterUpdate caused by: System.DmlException: Insert failed. First exception on row 0; first error: FIELD_INTEGRITY_EXCEPTION, field integrity exception: PricebookEntryId (pricebook entry currency code does not match opportunity currency code): [PricebookEntryId] Trigger.AssetRefreshOpp: line 56, column 1: []   This is my code:  trigger AssetRefreshOpp on Asset (after update) {      Pricebook2 ikmBook    = [SELECT Id,CurrencyIsoCode FROM Pricebook2 WHERE Id = '01s46000003K1zXAAS'];  List&lt;OpportunityLineItem&gt; oppLiList = new List&lt;OpportunityLineItem&gt;(); Opportunity opp; OpportunityLineItem oli; string refeshed;     List&lt;asset&gt; refreshedAss = [select Id,Contract__r.EndDate,OwnerId,quantity,Name,Refresh_Asset_To__c,Refresh_Asset_To__r.Id,AccountId,account.name from asset                                      where Id IN : Trigger.new                                      And Refresh_Asset__c = True];          for(asset myAss:refreshedAss){             // Create New Opportunity              Opportunity newopp =new Opportunity();   newopp.Name=myAss.account.name + ' ' + 'refreshed'; newOpp.AccountId = myAss.AccountId; newOpp.CloseDate = myAss.Contract__r.EndDate; newOpp.StageName = 'Create'; newOpp.RecordTypeID = '01246000000TfMZAA0'; newOpp.OwnerId = myAss.OwnerId; newOpp.Amount = 0; newOpp.Type= 'Existing Business'; newOpp.OM_Order_Type__c = 'Regular'; newOpp.CurrencyIsoCode = ikmBook.CurrencyIsoCode; newOpp.Pricebook2Id = ikmBook.Id;  insert newOpp;          List&lt;PriceBookEntry&gt; priceBookList = [SELECT Id, Product2Id,CurrencyIsoCode, Product2.Id, Product2.Name FROM PriceBookEntry WHERE  PriceBook2.isStandard=true LIMIT 1];               for(asset myAssets:refreshedAss){               OpportunityLineItem oli = new OpportunityLineItem();                oli.OpportunityId = newOpp.Id;                oli.Product2Id = myAssets.Refresh_Asset_To__r.Id;                oli.PriceBookEntryId = priceBookList[0].Id;                oli.UnitPrice = 0;               oli.Quantity = myAssets.Quantity;               oppLiList.add(oli);           }           insert oppLiList;               } }
66399
I have the following code:  const string Sql =      @"select distinct [name]        from tblCustomers        left outer join tblCustomerInfo on tblCustomers.Id = tblCustomerInfo.CustomerId         where (tblCustomer.Name LIKE '%@SEARCH%' OR tblCustomerInfo.Info LIKE '%@SEARCH%');";  using (var command = new SqlCommand(Sql, Connection)) {            command.Parameters.AddWithValue("@SEARCH", searchString);     ... }   This does not work, I tried this as well:  const string Sql =      @"select distinct [name]       from tblCustomers       left outer join tblCustomerInfo on tblCustomers.Id = tblCustomerInfo.CustomerId        where (tblCustomer.Name LIKE @SEARCH OR tblCustomerInfo.Info LIKE @SEARCH );";  using (var command = new SqlCommand(Sql, Connection)) {            command.Parameters.AddWithValue("@SEARCH", "'%" + searchString + "%'");     ... }   but this does not work as well. What is going wrong? Any suggestions?
73868
I need help. I am currently trying to test this code before uploading  public class CoreValuesExt { ApexPages.StandardController sc; public boolean readonly {get; set;} public Core_Values__c cv {get; set;} public integer countEdit = 1; public string buttonValue {get; set;} public integer recordScan;  public CoreValuesExt(ApexPages.StandardController sc) {     this.sc = sc;     cv = new Core_Values__c();     cv.Account__c = sc.getid();      readonly = true;     buttonValue = 'Edit';     recordScan = [SELECT COUNT() FROM Core_Values__c WHERE Account__c = :cv.Account__c];    if (recordScan != 0){    cv = [SELECT id, HSE__c, Professionalism_Integrity__c, Quality_Accuracy__c, Technology_Innovation__c, Timeliness__c, Value_for_money__c FROM Core_Values__c WHERE Account__c = :cv.Account__c];     }  }  public ApexPages.PageReference Save() {     return sc.Save(); }  public void ApplyAction() {     countEdit++;     Integer modolus = Math.mod(countEdit, 2);     String total = cv.HSE__c + cv.Professionalism_Integrity__c + cv.Quality_Accuracy__c + cv.Technology_Innovation__c + cv.Value_for_Money__c + cv.Timeliness__c;     if(modolus == 0)     {         readonly = false;         buttonValue = 'Save';     }     else     {         if(total != 'nullnullnullnullnullnull')            {         if (recordScan == 0){         insert cv;         readonly = true;         buttonValue = 'Edit';         }         else         {         update cv;         readonly = true;         buttonValue = 'Edit';         }         }     }    }   }  With this trigger.  trigger CoreValuesTrigger on Core_Values__c (before insert) {  Core_Values__c cvs = Trigger.new; CoreValuesExt.ApplyAction(cvs);  }   But when I try to save, I get a message saying:      Illegal assignment from List to   CoreValuesExt__Core_Values__c at line 3 column 1   "  How do I go through with this? I need help. Thanks
94370
Now, before you say it: I did Google and my hbm.xml file is an Embedded Resource.   Here is the code I am calling:  ISession session = GetCurrentSession(); var returnObject =  session.Get&lt;T&gt;(Id);   Here is my mapping file for the class:  &lt;?xml version="1.0" encoding="utf-8" ?&gt; &lt;hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"&gt;   &lt;class name="HQData.Objects.SubCategory, HQData" table="SubCategory" lazy="true"&gt;     &lt;id name="ID" column="ID" unsaved-value="0"&gt;       &lt;generator class="identity" /&gt;     &lt;/id&gt;      &lt;property name="Name" column="Name" /&gt;     &lt;property name="NumberOfBuckets" column="NumberOfBuckets"  /&gt;     &lt;property name="SearchCriteriaOne" column="SearchCriteriaOne" /&gt;      &lt;bag name="_Businesses" cascade="all"&gt;       &lt;key column="SubCategoryId"/&gt;       &lt;one-to-many           class="HQData.Objects.Business, HQData"/&gt;     &lt;/bag&gt;      &lt;bag name="_Buckets" cascade="all"&gt;       &lt;key column="SubCategoryId"/&gt;       &lt;one-to-many          class="HQData.Objects.Bucket, HQData"/&gt;     &lt;/bag&gt;    &lt;/class&gt; &lt;/hibernate-mapping&gt;   Has anyone run to this issue before?  Here is the full error message:   MappingException: No persister for:  HQData.Objects.SubCategory]NHibernate.Impl.SessionFactoryImpl.GetEntityPersister(String entityName, Boolean throwIfNotFound)  in c:\CSharp\NH2.0.0\nhibernate\src\NHibernate\Impl\SessionFactoryImpl.cs:766 NHibernate.Impl.SessionFactoryImpl.GetEntityPersister(String entityName)  in c:\CSharp\NH2.0.0\nhibernate\src\NHibernate\Impl\SessionFactoryImpl.cs:752 NHibernate.Event.Default.DefaultLoadEventListener.OnLoad(LoadEvent event, LoadType loadType)  in c:\CSharp\NH2.0.0\nhibernate\src\NHibernate\Event\Default\DefaultLoadEventListener.cs:37 NHibernate.Impl.SessionImpl.FireLoad(LoadEvent event, LoadType loadType)  in c:\CSharp\NH2.0.0\nhibernate\src\NHibernate\Impl\SessionImpl.cs:2054 NHibernate.Impl.SessionImpl.Get(String entityName, Object id)  in c:\CSharp\NH2.0.0\nhibernate\src\NHibernate\Impl\SessionImpl.cs:1029 NHibernate.Impl.SessionImpl.Get(Type entityClass, Object id)  in c:\CSharp\NH2.0.0\nhibernate\src\NHibernate\Impl\SessionImpl.cs:1020 NHibernate.Impl.SessionImpl.Get(Object id)  in c:\CSharp\NH2.0.0\nhibernate\src\NHibernate\Impl\SessionImpl.cs:985 HQData.DataAccessUtils.NHibernateObjectHelper.LoadDataObject(Int32 Id)  in C:\Development\HQChannelRepo\HQ Channel Application\HQChannel\HQData\DataAccessUtils\NHibernateObjectHelper.cs:42 HQWebsite.LocalSearch.get_subCategory()  in C:\Development\HQChannelRepo\HQ Channel Application\HQChannel\HQWebsite\LocalSearch.aspx.cs:17 HQWebsite.LocalSearch.Page_Load(Object sender, EventArgs e)  in C:\Development\HQChannelRepo\HQ Channel Application\HQChannel\HQWebsite\LocalSearch.aspx.cs:27 System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +15 System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +33 System.Web.UI.Control.OnLoad(EventArgs e) +99 System.Web.UI.Control.LoadRecursive() +47 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1436   Update, here's what the solution for my scenario was: I had changed some code and I wasn't adding the Assembly to the config file during runtime.
18034
when i try to save the following code, i got the error below. Following same instructions given in this link, but still errors. Am i doing anything wrong here? please suggest.    @isTest private class WebSvcCalloutTest {     @isTest static void testEchoString() {         Account a = new Account(name='Tester',SAP_KUNNR__c='1172');         insert a;                       // This causes a fake response to be generated         Test.setMock(WebServiceMock.class, new WebServiceMockImpl());      } }   Error:  Save error: Method does not exist or incorrect signature: Test.setMock(Type, WebServiceMockImpl)    WebSvcCalloutTest.cls         @isTest global class WebServiceMockImpl implements WebServiceMock {    global void doInvoke(            Object stub,            Object request,            Map&lt;String, Object&gt; response,            String endpoint,            String soapAction,            String requestName,            String responseNS,            String responseName,            String responseType) {          sapComDocumentSapSoapFunctionsMcS.Z_GSSMWFM_HNDL_EVNTRQST00 sap1 = new sapComDocumentSapSoapFunctionsMcS.Z_GSSMWFM_HNDL_EVNTRQST00();                Map&lt;String,String&gt; mapSAP = new Map&lt;String,String&gt; {};         sapComDocumentSapSoapFunctionsMcS.ZgssmbstDatarcrd01 req = new sapComDocumentSapSoapFunctionsMcS.ZgssmbstDatarcrd01();               sapComDocumentSapSoapFunctionsMcS.ZGssmwfmHndlEvntrqst00Response_element ret =  sap1.ZGssmwfmHndlEvntrqst00('',req);         response.put('response_x', ret);     } }
110550
For a new project that I'm doing in PHP I've created an SQLMethods class to connect to the database and perform queries. Tonight was the first night that I actually got to test it (I wrote it a week or so ago and forgot about it) and an unexpected error occured: When it was calling my ExecuteQuery() function, it wouldn't use the database I selected in the constructor.  The constructor:      public function SQLMethods() {         $SQLConnection = mysql_connect($SQLDBAddress, $SQLUserName, $SQLPassword);          if (!$SQLConnection) {             die('Could not connect: ' . mysql_error());         }          mysql_select_db($SQLDB, $SQLConnection);     }   The function in question:      public function ExecuteQuery($Query) {         mysql_query($Query, $SQLConnection) or die('Could not perform query: ' . mysql_error());     }   Does anyone see what the issue might be? Does the connection close after the constructor completes?