Inserting details into sql server?

Hi i have a requirement to insert values into sql server table in my jira plugin , i created a new table with three columns , i wrote the following code to insert values into database table , but the values are not inserting , following is my code snipet

namevalue = getName();
        desvalue = getDescription();
        roleValue = getRole();

   Class.forName("net.sourceforge.jtds.jdbc.Driver" );
            Connection con =DriverManager.getConnection("jdbc:jtds:sqlserver://localhost:1433/jiradb","jirauser","jirauser");
  "test connection..");
            String query = "insert into jiradb.dbo.testworklog values(namevalue,desvalue,rolevalue)";
            Statement stmt = con.createStatement();
  "values inserted in database table.. ");

Can any body guide me where i did the mistake .

Thanks in advance

1 answer

You should use your variables in the query string, like this :

String query = "insert into jiradb.dbo.testworklog values("+namevalue+","+desvalue+","+rolevalue+")";

Best regards


Suggest an answer

Log in or Sign up to answer
Community showcase
Published Nov 27, 2018 in Portfolio for Jira

Introducing a new planning experience in Portfolio for Jira (Server/DC)

In the past, Portfolio for Jira required a high degree of detail–foresight that was unrealistic for many businesses to   have–in   order to produce a reliable long-term roadmap. We're tur...

2,762 views 18 21
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you