Results 1 to 19 of 19
  1. #1
    kavish is offline Member
    Join Date
    Aug 2013
    Posts
    8
    Rep Power
    0

    Exclamation netbeans project wont work on another pc ?

    Guys, help me out here plsss..
    I made my project in my PC at home and I copied the entire folder where i saved my program and pasted it in the school PC for my teacher to check it. But unfortunately.. it doesn't run.. I used JFrame.. huhuh how to do this? do i have to redo my entire program for this to work? HOw how how.. PLs helppppp :confused:

  2. #2
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    3,047
    Rep Power
    4

    Default Re: netbeans project wont work on another pc ?

    "It doesn't work" is not information, like this nobody can help you. What error are you getting?
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  3. #3
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,189
    Rep Power
    19

    Default Re: netbeans project wont work on another pc ?

    Quote Originally Posted by kavish View Post
    netbeans project wont work on another pc ?
    Moved from Other IDEs.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  4. #4
    kavish is offline Member
    Join Date
    Aug 2013
    Posts
    8
    Rep Power
    0

    Default Re: netbeans project wont work on another pc ?

    Note: Some input files use or override a deprecated API.
    Note: Recompile with -Xlint:deprecation for details.

    it opens the screen , but cant write to the databse , it can read , but dont update , delete , add , etc

  5. #5
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    3,047
    Rep Power
    4

    Default Re: netbeans project wont work on another pc ?

    so it does run, it just doesn't do what you want.

    And now you add a database into the mix. What database?
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  6. #6
    kavish is offline Member
    Join Date
    Aug 2013
    Posts
    8
    Rep Power
    0

    Default Re: netbeans project wont work on another pc ?

    its a miscroft access db , i was trying to do the databse in netbeans , must i email it to you and you could have a look , its really important i get this sorted out asap
    thanks

  7. #7
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,432
    Rep Power
    18

    Default Re: netbeans project wont work on another pc ?

    If it can read but not update then there's something up with the database?
    Is it the same version of the database?
    What driver are you using for your JDBC connection?
    How are you handling exceptions?
    Are you printing the stack trace, or simply ignoring the exception?
    Please do not ask for code as refusal often offends.

  8. #8
    kavish is offline Member
    Join Date
    Aug 2013
    Posts
    8
    Rep Power
    0

    Default Re: netbeans project wont work on another pc ?

    odbc database , access 2007 , can i email it you and have a look , im a student and dont know much as 1st time we are learning netbeans.

  9. #9
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,432
    Rep Power
    18

    Default Re: netbeans project wont work on another pc ?

    This is an open forum, not a one-to-one help site.

    You shouldn't be doing JDBC as a first time exercise in Java. Pure and simple.

    You didn't answer my questions, though.
    Is the database a different version on the macine that fails compared to the machine it works on?
    What JDBC driver are you using? Since it's an Access databse I'm going to guess it's the JDBC-ODBC driver, in which case are the versions of Java the same on both machines?

    And most important of all, are you handling exceptions properly?
    In fact, when it fails to create/update/delete something in the database is it because you get an exception?
    Please do not ask for code as refusal often offends.

  10. #10
    kavish is offline Member
    Join Date
    Aug 2013
    Posts
    8
    Rep Power
    0

    Default Re: netbeans project wont work on another pc ?

    yes i have all same version on the pc, it has exception handling as well

  11. #11
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,432
    Rep Power
    18

    Default Re: netbeans project wont work on another pc ?

    So, are you getting an exception or is it simply not updating/deleteing/adding to the database?
    Do you have logging in your application (even plain System.out.println calls) that show exactly what is happening in your code?
    Does that logging show that it is even attempting to add/remove/update rows?
    Does it show exactly what the SQL used is?
    Please do not ask for code as refusal often offends.

  12. #12
    kavish is offline Member
    Join Date
    Aug 2013
    Posts
    8
    Rep Power
    0

    Default Re: netbeans project wont work on another pc ?

    yes , i have a login screen , it just dont add , delete and update but can read, i have used sql , it dont show any error message , i have 2 different versions of netbeans , will that make a diffrence?
    it also says this when i run it
    Driver successfully loaded
    [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
    BUILD SUCCESSFUL (total time: 28 seconds)

  13. #13
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,432
    Rep Power
    18

    Default Re: netbeans project wont work on another pc ?

    "Data source name not found and no default driver specified"

    Um, if it can't find the data source then I'm surprised it can read anything.
    It can't find the database.
    Since that's an ODBC error then I would guess there isn't an ODBC data source declared.
    And before you ask I have no idea how to do that and would have to look it up.

    If you are sure you are successfully reading from the databse then you need to show how you make the connection for reading, and whether it is different to the writing part.
    Please do not ask for code as refusal often offends.

  14. #14
    kavish is offline Member
    Join Date
    Aug 2013
    Posts
    8
    Rep Power
    0

    Default Re: netbeans project wont work on another pc ?

    thats what it says for the pc which it dont work , i was doing the database in netbeans , it might be easier for me to send it to you if you want so you can see whats wrong and how to resolve it , this project is really important to me , carrys alot of marks for the final report. maybe you can inbox me your email , il send the rar file

  15. #15
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,432
    Rep Power
    18

    Default Re: netbeans project wont work on another pc ?

    I do have a job you know.

    And no, this isn't a help desk.
    I have asked what your connection code looks like.
    It should be possible for you to paste that here as it should be plain old Java.

    I've explained the error, which is a Microsoft ODBC error, not a Java error. It means you are missing an ODBC data source.
    Please do not ask for code as refusal often offends.

  16. #16
    kavish is offline Member
    Join Date
    Aug 2013
    Posts
    8
    Rep Power
    0

    Default Re: netbeans project wont work on another pc ?

    /*
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    */
    package newcomp;
    import java.sql.*;
    import javax.swing.JOptionPane;
    /**
    *
    * @author fox
    */
    public class Db {
    static Connection con;
    Statement st;
    ResultSet rs;
    PreparedStatement pst;
    static Connection conn;


    public Db(){
    // connect();

    newconn();
    }

    public void connect(){
    try {
    newconn();
    st = con.createStatement(ResultSet.TYPE_SCROLL_INSENSIT IVE, ResultSet.CONCUR_UPDATABLE);
    String sql = "select * from voter";
    rs = st.executeQuery(sql);

    }catch (Exception ex) {

    }
    }
    public void select (String vakuru){
    try{
    /*String driver = "sun.jdbc.odbc.JdbcOdbcDriver";
    Class.forName(driver);
    String bd = "jdbc:odbc:matric";
    con = DriverManager.getConnection(bd);*/
    //newconn();
    st = con.createStatement(ResultSet.TYPE_SCROLL_INSENSIT IVE, ResultSet.CONCUR_UPDATABLE);
    System.out.println ("Connection to database successfully established");
    String sql = vakuru;
    rs = st.executeQuery(sql);

    } catch (Exception ex){
    System.out.println(ex.getMessage());
    }

    }

    public static Connection connn(){
    try{
    newconn();
    }catch (Exception ex){

    }
    return con;
    }
    public static Connection newconn(){

    //load the driver
    try
    {
    Class.forName ("sun.jdbc.odbc.JdbcOdbcDriver");
    System.out.println ("Driver successfully loaded");
    }
    catch (ClassNotFoundException c)
    {
    System.out.println ("Unable to load database driver");
    }


    //connect to the database
    try
    {
    String filename = "matricComp.mdb";

    String database = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=";
    database += filename.trim () + ";DriverID=22;READONLY=false}";
    con = DriverManager.getConnection (database, "", "");


    }
    catch (Exception e)
    {
    System.out.println (e.getMessage());
    }
    return con;
    }

    public void updatevoter(int id, String fname, String lname, String nid, String address, String username, String password ){
    String sql = "Update voter set Firstname =?, Surname =?, NationalID=?, Address=?, Useraname=?, Password=? Where VoterID=?";
    try {
    pst = conn.prepareStatement(sql);

    pst.setString(1, fname);
    pst.setString(2, lname);
    pst.setString(3, nid);
    pst.setString(4, address);
    pst.setString(5, username);
    pst.setString(6, password);
    pst.setInt(2, id);
    rs = pst.executeQuery();
    rs.next();
    System.out.println(rs.getString("VoteCheck"));
    } catch (Exception ex){

    System.out.println(ex.getMessage());

    }



    }
    public void updateRecord(String sqlStmt)
    {
    conn = newconn();
    try
    {
    Statement stmt = conn.createStatement ();
    stmt.executeUpdate(sqlStmt);
    stmt.close ();
    }
    catch(Exception e)
    {
    System.out.println(e);
    }
    }

    public void upt (){

    con = newconn();
    try{
    st = con.createStatement(ResultSet.TYPE_SCROLL_INSENSIT IVE, ResultSet.CONCUR_UPDATABLE);
    String sql = "Update voter set name = aston where voterId = 3";
    rs = st.executeQuery(sql);



    }catch (Exception ex){
    System.out.println(ex.getMessage());
    }

    }
    }

  17. #17
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,189
    Rep Power
    19

    Default Re: netbeans project wont work on another pc ?

    Please go through the Guide For New Members and BB Code List - Java Programming Forum - Learn Java Programming and edit your post accordingly.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  18. #18
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,189
    Rep Power
    19

    Default Re: netbeans project wont work on another pc ?

    And while you're doing that, get rid of the inane IDE-generated comments. We really don't want to see this here:
    Java Code:
    /*
     * To change this template, choose Tools | Templates
     * and open the template in the editor.
     */
    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  19. #19
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,432
    Rep Power
    18

    Default Re: netbeans project wont work on another pc ?

    Java Code:
    System.out.println (e.getMessage());
    You should be using e.printStackTrace() so you know exactly where and why the exception was thrown.
    Java Code:
    }catch (Exception ex) {
    
    }
    You have a few of these, which should also have printStackTrace().
    Why have you got two Connection objects? 'con' and 'conn'?
    Java Code:
    String sql = "Update voter set name = aston where voterId = 3";
    That will throw a SQLException. I'm assuming 'name' is a VARCHAR (or String or whatever it is Access uses for those).

    That's for starters.
    So tidy that up, and get a proper exception and stack trace and repost the code (in code tags so it's formatted correctly) and we might be able to sort it out.
    Please do not ask for code as refusal often offends.

Similar Threads

  1. Why wont it work???
    By fredrik8719 in forum New To Java
    Replies: 0
    Last Post: 04-08-2012, 07:38 PM
  2. Why Wont This Work???
    By Billywizz in forum New To Java
    Replies: 11
    Last Post: 03-09-2011, 02:33 AM
  3. why wont the %.2f work here?
    By jjth39347 in forum New To Java
    Replies: 2
    Last Post: 03-06-2011, 05:55 AM
  4. importing JCurses wont work!
    By TheBreadCat in forum New To Java
    Replies: 0
    Last Post: 02-16-2011, 08:46 PM
  5. project runs in netbeans but .jar wont work
    By Zeo7 in forum New To Java
    Replies: 3
    Last Post: 12-16-2010, 04:21 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •