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 Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

2,782 views 11 18
Join discussion

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
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot